Docs

Widgets

Every attribute, property, theme option and event of <typomat-preview>, with its values and default.

For how to use them, see the preview widgets guide. To see them working, see the widgets page.

HTML
<script src="https://engine.typomat.app/typomat/widget.js" async></script>
<typomat-preview></typomat-preview>

Attributes

All are optional. A value the widget can't use falls back to the default, and removing an attribute does the same. Changes take effect at once. The theme attributes are below.

AttributeValuesDefaultMeaning
variantmini or fullminiA preset. mini is line; full is line grid paragraph parameters, and request too with show-request. show wins when given.
showPieces, space-separated: line waterfall grid paragraph parameters requestThe variant'sWhat shows, top to bottom, each once. A word it doesn't know is skipped and reported in ignored. If it knows none, the variant's pieces show.
show-requestPresent, or "false"OffAdds request to the full preset.
textUp to 120 charactersHandglovesThe line's and the waterfall's text. Line breaks and control characters become spaces. Blank gives the default.
size10–160 pixels32 with the mini preset, otherwise picked from the width (40–128)The line's size. The line shrinks to fit the widget, and never grows past this.
sizes4 to 8 numbers, each 8–200 pixels, separated by spaces or commas14 24 48 96The waterfall's sizes, a row each. Fewer than four numbers gives the default; past eight, the rest are dropped.
groupsAny of letters figures accented extendedAll fourThe grid's tabs, in this order. One group shows no tabs.
paragraphUp to 600 charactersA pangramThe paragraph's text. Line breaks and control characters become spaces.
lines1–205The paragraph's height, in lines. Longer text is cut off; typed text scrolls to keep the caret in view.
alignstart or centerstartFor the line, the waterfall and the paragraph.
editablePresent, line, paragraph, line paragraph, or "false"OffLets visitors type into the line or the paragraph. Present on its own means the line.
placeholderUp to 120 charactersNoneShown muted in an empty editable line, and gone with the first keystroke. Without one, the line starts with text.
controlssize, theme, or size themeNoneControls for the visitor: a slider for the line's size, and a light/dark switch.
parametersA JSON objectThe engine's defaultsThe parameters, by name, as POST /api/v1/fonts takes them. Broken JSON counts as none.
param-<name>A numberOne parameter, laid over parameters: param-weight="120". Names ignore case and dashes, so param-x-height is xHeight.
nameUp to 64 charactersTypomat FontThe font name in the request piece's body. The API uses the same default.
labelUp to 120 charactersFont previewThe widget's name for screen readers, and the iframe's title.
themeA JSON objectEvery theme option at once, dark included. The theme attributes below are laid over it.

Properties

For your page's script. Each can be set before the script has loaded, and is picked up when it does.

PropertyTakesMeaning
parametersAn object, or a JSON stringLaid over the parameters and param-* attributes, so your script has the last word. Setting the parameters attribute again drops it.
themeAn object, or a JSON stringLaid over the theme attribute and the theme attributes. Setting the theme attribute again drops it.
showA string, or an array of piece namesIn place of the show attribute, until that attribute changes.

Theme

Each option is an attribute of its own, or a key of the theme JSON attribute or property. Order of precedence, last wins: the theme attribute, the theme attributes, the theme property.

OptionValuesDefaultMeaning
modelight, dark or autolightauto follows the visitor's system setting, and changes with it. Anything else is light.
backgroundA colour#FFFFFF light, #0A0A0A darkBehind everything. transparent lets your page show through.
inkA colour#0A0A0A light, #FFFFFF darkThe letters, the labels and the mark.
accentA colour#1A2BFF light, #FFD400 darkThe current tab's underline, the selection, the Copy button and the size slider.
mutedA colour#6B6B6B light, #9A9A9A darkNotes, headings, the other tabs, the grid's rules and the placeholder.
fontA font-family list of up to 6 namesTypomat's own UI fontFor the labels, tabs and notes, never the letters. Only fonts the visitor's device has, and generic families.
radius0–48 pixels8The corners.
padding0–64 pixels16The space inside the edge.
darkAn object of background, ink, accent and mutedColours used only while the widget is dark. In the theme JSON or property only.
A colour
#rgb, #rgba, #rrggbb or #rrggbbaa; rgb(), rgba(), hsl() or hsla() with plain numbers, commas or spaces, and an optional alpha; or transparent. Up to 64 characters. Colour names, var() and calc() are ignored.
A font list
Up to six comma-separated names, each up to 48 letters, digits, spaces, dashes and underscores, quoted or not. One bad name drops the whole list. Generic families (serif, sans-serif, monospace, system-ui, ui-serif, ui-sans-serif, ui-monospace, ui-rounded, cursive) work, and system-ui, sans-serif is added at the end.
Pixels
A number, a string of one, or one ending in px: 12, "12", "12px". Other units give the default.
Which colours
light: the light defaults under your colours. dark: the dark defaults under your colours, then dark. auto follows the system: light as light, dark with only dark over the dark defaults. The visitor's light/dark switch (controls="theme") keeps your colours in your own mode and uses the defaults, and dark, in the other.

Pieces

The words show takes, top to bottom in the order given. variant="mini" is line; variant="full" is line grid paragraph parameters, with request after them given show-request.

PieceShows
lineOne line of text, as large as size and the width allow.
waterfalltext at several sizes, a row each. A row too wide for the widget is drawn as large as fits, never cut.
gridEvery character, a group at a time, with tabs to switch.
paragraphA wrapped paragraph, a fixed number of lines tall.
parametersThe parameters as the engine reads them: known names only, clamped to their ranges.
requestThe JSON body POST /api/v1/fonts would get for them, with a Copy button.

typomat-status

A CustomEvent on the element, sent once the widget has its first settings and whenever what it reports changes. It doesn't bubble. Its detail has four arrays of strings:

FieldLists
unknownParameter names that aren't Typomat's. Left out of the drawing and the request.
invalidParameters whose value isn't a number. Left out. If the parameters attribute is the text [object Object], this starts with a hint: pass JSON.stringify(...) or set the property.
missingCharacters of your own text and paragraph that Typomat has no drawing for. Never anything a visitor typed.
ignoredWords in show, groups, editable, controls or align that mean nothing to the widget.

Limits

Text
The line and waterfall's text and the placeholder up to 120 characters, the paragraph up to 600, the name up to 64, the label up to 120. Longer is cut.
Parameters
The first 200 names. Values are clamped to each parameter's range.
One update
Everything the element sends at once, as JSON, up to 32,000 characters. A bigger one is dropped, and the widget keeps showing the last.
Height
Set by the widget, up to 4,000 pixels.

Content Security Policy

What a page with its own policy adds to it, and all it needs: the loader adds no style text to your page, so style-src needs nothing.

Content-Security-Policy
script-src https://engine.typomat.app;
frame-src https://engine.typomat.app;