Text card
A :::textcard turns a few words into an image: a frame (safe margins, a background) around the
content of an existing block. There is no new text engine and no image file: the card is rendered by
code, in every language of the story. In v1 it plays in the motion format (a film shot) and in the
webstory format (a card); a deck slide or a page comes later.
Live demo
Syntax
Markdown
In a film, --- type= is the same shot written without the directive: the
content of the scene is the content of the card. A scene that holds one :::textcard is a text
card, without type=.
Variants
| Variant | Dresses | Content |
|---|---|---|
quote | statement | one paragraph, then an optional — attribution line |
title | title | a # heading, then an optional subtitle line |
stat | stat | a # value and its label line, with source="…" (required) |
caption | statement | one short paragraph |
list | list | an optional heading and a bullet list of three to five items |
In a film, each variant enters like the block it dresses: a quote reveals like a statement, a
number pops like a stat.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
variant | see above | — | Required |
background | theme | gradient | theme | The theme surface, or a gradient of the theme colours |
source | string | — | Where the number of a stat comes from; never translated |
id | string | — | Stable id of the card, the same in every language |
mark | string | — | A watermark, 40 characters at most; never translated |
mark writes a short line (a handle, a site name) in the bottom corner of the safe area, in the
muted colour, under the fitted text, which gives up its height. In a film it stays still while the
text enters. On a webstory card, its contrast is checked like any muted line.
Text fit
The card looks for the largest font size that fits, by dichotomy, measured in the browser between
the bounds of its variant. Before the measure, and on the server, the text is at the smallest size:
nothing can overflow. A text too long even at the smallest size is an error, with the language of
the file: story.. The budgets are
provisional and move once the goldens have measured the cards.
Errors
Every problem points to its line in the story, and nothing is corrected silently:
- an unknown variant, or content that does not match the variant;
- a
statwithoutsource="…": no number is shown without its source; - a list of fewer than three or more than five items;
- a text that overflows at minimum size.
JSON twin
In the typed JSON of a story, the directive stays in the scene body, like any Markdown. The props
are validated by TextCardPropsSchema and TextCardBlockSchema of @recit/.
In code
@recit/ holds the pure module: readTextCard (the reader of the directive and
its variants), textCardToHast and textCardDirective (the static card in compiled HTML) and the
bounds of the fit. TextCard and useFitText (React) are exported by @recit/, and the
animated block textcard by @recit/.
See the cards on the images page of motion.recit.dev.