Log in Start free trial โ
Reference
Fontdue.jsGraphQLDemo templateGuides
WebflowWordpress + Lay ThemeWordpress + SempliceNext.js (App Router)Next.js (Pages Router)Python + FlaskInformation
Whatโs newFull-service website developmentManaging your font catalogVariable fontsFont licensesWebfontsCross-origin accessPayments with StripeTaxTest fontsTest modeManage your Fontdue subscriptionLaunching your siteTroubleshootingUpdates
Update 001Update 002Update 003ยฉ Fontdue, 2022
Fontdue.js
Add this snippet to your site's HTML head. Replace https://your-site.fontdue.com
with your Fontdue site URL.
<link rel="stylesheet" href="https://js.fontdue.com/fontdue.css">
<script type="module">
import fontdue from "https://js.fontdue.com/fontdue.esm.js";
fontdue.initialize({
url: "https://your-site.fontdue.com",
config: {
typeTester: {
size: {
min: 6,
max: 480,
label: 'Size',
},
selectable: true,
textInput: false,
groupEdit: false,
initialMode: 'local',
shy: true,
buyButton: true,
selectButtonLabel: 'Buy',
selectButtonStyle: 'outlined',
},
},
});
</script>
Make sure you have allowed Cross-origin API access for your domain.
Read on for all the available config options, the range of different components you can add to your pages, and the optional element attribute API.
React
Fontdue.js React components are available via NPM.
If you are using React to build your site, we recommend using these React components.
npm install fontdue-js
Config
These options below describe all the available config options in the fontdue.initialize()
script.
Property | Type | Description |
---|---|---|
url |
| Your Fontdue site URL |
typeTester |
| See Type Tester config below |
form |
| See Form config below |
storeModal |
| See Store Modal config below |
Type Tester config
Property | Type | Description |
---|---|---|
selectable |
| Makes the font family and style selectable with a dropdown |
textInput |
| Enables the input to control the font size value in pixels |
groupEdit |
| Whether to enable or disable the group edit toggle (Affect all styles) |
initialMode |
| The mode refers to the toggle in the UI: Affect all styles. |
shy |
| Controls are hidden until the user hovers or focuses the type tester component. |
buyButton |
| (Renamed to |
selectButton |
| Enables the Select button. Clicking this button opens the StoreModal with the relevant font style selected |
selectButtonLabel |
| The select button label (defaults to |
selectButtonStyle |
| Choose from the button styles |
toolsPosition |
| Controls display of the toolbar. |
truncate |
| Set to |
bulletStyle |
| Choose bullet styles, e.g. in the OpenType features panel. Defaults to |
autofitOnChange |
| For type testers with |
openTypeFeatures |
| See Type Tester OpenType features config below |
variableAxesPosition |
| Controls where variable axes appear. |
alignmentButtons |
| Set to |
initialAlignment |
| Defaults to |
min |
| Min font size |
max |
| Max font size |
size |
| Controls for the Size slider. See Slider config below. Defaults to |
lineHeight |
| Controls for the Line height slider. See Slider config below. Defaults to |
Type Tester OpenType features config
Property | Type | Description |
---|---|---|
interactionStyle |
| Adjusts the user experience for selecting OT features. In the default |
columns |
| Control how the list of OpenType features appear in columns. See OpenType features column config below. If left empty, features will appear in the order set in the Type Testers section of the CMS, automatically organized into 4 columns |
selectionStyle |
| Selection style for features in the |
buttonLabel |
| Label for the button, defaults to |
OpenType features column config
Property | Type | Description |
---|---|---|
features |
| List of features to display for a particular column. You may specify only the feature code (e.g. |
range |
| Number of columns for this column config to span, for example you may have a variable number of stylistic set features you want to spread across 2 columns. Defaults to |
Slider config
Property | Type | Description |
---|---|---|
min |
| Minimum size for the slider |
max |
| Maximum size for the slider |
label |
| Label for the slider. Set to |
Form config
Property | Type | Description |
---|---|---|
checkboxStyle |
| Icon style for checkboxes across components. Defaults to |
Store Modal config
Property | Type | Description |
---|---|---|
indexLayout |
| Alternate layouts for the Store Modalโs initial โbrowseโ index page. Defaults to |
productLicensesPosition |
| On the product pages, controls the position of licenses selection, above or below the product selection. Defaults to |
indexExcludeTags |
| You may exclude some font collections from the store index page by specifying tags to exclude, e.g. |
Components
Store Modal
The Store Modal component is a self-contained shopping experience containing a directory of fonts to browse, and integrates the cart and checkout.
Ensure this tag is present on every page, by putting it in your site's layout template (it could go right above the snippet above). You can add it right before the snippet above.
<fontdue-store-modal></fontdue-store-modal>
Buy Button
A button which when clicked opens the Cart to the relevant collection, and selects the collection.
Renders a button with the text Buy {{collection-name}}
<fontdue-buy-button
collection-id="{{id}}"
collection-name="Example"
></fontdue-buy-button>
Cart Button
A button to open the Store Modal. If the user has items in their cart, the button will navigate straight to the Cart screen. Otherwise it opens the fonts index.
<fontdue-cart-button button-style="icon">
</fontdue-cart-button>
<fontdue-cart-button label="Shop">
</fontdue-cart-button>
Character Viewer
An interactive character/glyph explorer.
<fontdue-character-viewer collection-id="{{my-id}}">
</fontdue-character-viewer>
Property | Type | Description |
---|---|---|
collection-id or collection-slug |
| Identifier for collection |
Customer Login Form
A form for customers to log in and retrieve their order history. When they enter their email address, they receive a link to a Fontdue-hosted page to view orders.
<fontdue-customer-login-form>
</fontdue-customer-login-form>
Property | Type | Description |
---|---|---|
submit-label |
| Label for the submit button, defaults to "Submitโ |
Type Testers
A group of type tester components for a collection. You must first add content for the collection's type testers through the Fontdue dashboard.
<fontdue-type-testers
collection-id="{{my-id}}"
default-mode="local"
autofit="true">
</fontdue-type-testers>
Property | Type | Description |
---|---|---|
collection-id or collection-slug |
| Identifier for collection |
default-mode |
| The mode refers to the toggle in the UI: Affect all styles. |
autofit |
| Set to |
tags |
| Comma-separated list of tags. Will render only type testers that include these tags |
exclude-tags |
| Commas-separate list of tags to exclude. Will exclude type testers that include these tags |
Type Tester (standalone)
A single instance of the type tester where you enter the content as widget attributes, rather than managing the content in the Fontdue admin.
<fontdue-type-tester
family-name="My Font Family"
style-name="Bold"
font-size="96"
line-height="1.5"
content="The quick brown fox.."
features="onum,tnum,frac,smcp,c2sc,ss01,ss02"
autofit="true"
></fontdue-type-tester>
Property | Type | Description |
---|---|---|
family-name |
| Font family name (must have been already uploaded to your Fontdue admin) |
style-name |
| The name of the style from the family to display. Note that variable fonts have one or more Font Styles, these represent each font file that make up the designspace of the font. |
font-size |
| Initial font size in pixels. |
line-height |
| Line-height as a proportional value where |
content |
| The initial content to display. |
features |
| Comma-separated list of opentype feature codes to expose as options to users. (e.g. |
features-selected |
| Comma-seperated list of opentype feature codes to be selected by default |
autofit |
| See the |
variable-settings |
| If this type tester points to a variable font, set the variable font settings here with a comma-separated list of settings. Each setting must have the format |
axes |
| Comma-separated list of variable axes to expose (e.g. |
Test Fonts Form
Displays a form for users to enter their information and download test fonts. Make sure you have configured Test Fonts for this to work.
<fontdue-test-fonts-form>
</fontdue-test-fonts-form>
Property | Type | Description |
---|---|---|
download-label |
| Text for the download button. Defaults to โDownload test fontsโ |
agreement-label |
| Replaces the default EULA agreement text |
newsletter-checkbox-checked |
| Include this attribute to set the newsletter opt-in checkbox checked by default. |
Newsletter Signup
A newsletter signup form. Customers entering their information here simply adds them as a Customer in the Fontdue CMS.
<fontdue-newsletter-signup opt-in-label="I agree to receive direct email marketing" opt-in-checkbox-checked>
</fontdue-newsletter-signup>
Element attribute API
If you prefer to use your own elements, you can add Fontdue interactivity to them by adding custom fontdue-*
attributes. They will become interactive after the Fontdue.js scripts are loaded.
Example: Cart Button
Create your own cart button that opens the Store Modal by adding the fontdue-click="open-store-modal"
attribute. The example below includes the optional fontdue-store-route
attribute which always opens to the Cart page, even if itโs empty.
<button
type="button"
fontdue-click="open-store-modal"
fontdue-store-route="cart">
Cart
</button>
<fontdue-cart-button>
is aware of how many items are in the cart, and will prevent navigating to the modalโs cart page if there are no cart items, but this behavior isnโt implemented on the fontdue-store-route
attribute.Example: Buy Button
Create a buy button which opens the modal at a particular product page:
<button
type="button"
fontdue-click="open-store-modal"
fontdue-store-route="product/{{ collection_id }}">
Buy
</button>
The Collection ID can be found in the Fontdue admin panel, on the Font collectionโs Widget codes tab, or through the GraphQL API.
Extend this functionality to select a particular product with the fontdue-store-select
attribute:
<button
type="button"
fontdue-click="open-store-modal"
fontdue-store-route="product/{{ collection_id }}"
fontdue-store-select="{{ sku_id }}">
Buy
</button>
You can find SKU IDs in the Fontdue admin panel. A SKU can be attached to various products including Collections, Bundles and Font styles. For collections, find it on the Widget codes tab. For individual font styles as well as bundles, find it under the Price field. A product must have a price to get a SKU ID and be selectable.
- Fontdue.js
- React
- Config
- Type Tester config
- Type Tester OpenType features config
- OpenType features column config
- Slider config
- Form config
- Store Modal config
- Components
- Store Modal
- Buy Button
- Cart Button
- Character Viewer
- Customer Login Form
- Type Testers
- Type Tester (standalone)
- Test Fonts Form
- Newsletter Signup
- Element attribute API
- Example: Cart Button
- Example: Buy Button