Skip to content

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

MarkdownMarkdown
--- id=quote :::textcard{variant=quote background=theme} Lorem ipsum dolor sit amet, consectetur adipiscing elit. — Lorem Ipsum :::

In a film, --- type=textcard variant=quote 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

VariantDressesContent
quotestatementone paragraph, then an optional — attribution line
titletitlea # heading, then an optional subtitle line
statstata # value and its label line, with source="…" (required)
captionstatementone short paragraph
listlistan 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

AttributeTypeDefaultDescription
variantsee above—Required
backgroundtheme | gradientthemeThe theme surface, or a gradient of the theme colours
sourcestring—Where the number of a stat comes from; never translated
idstring—Stable id of the card, the same in every language
markstring—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.fr.md:12 (textcard): text overflows at minimum size: …. 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 stat without source="…": 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/core/schema.

In code

@recit/components/textcard 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/components, and the animated block textcard by @recit/motion-blocks.

See the cards on the images page of motion.recit.dev.

Last modified on