View raw

text#

Static or template-driven text with full typographic styling and optional reveal mask. Inherits everything in common fields; the tables below cover what's specific to text.

interface TextElement extends BaseElement {
  type: 'text';
  text?: string;
  text_template?: string;
  spans?: TextSpan[];
  vars?: Record<string, number | string | Keyframe[]>;
  number_format?: 'integer' | 'comma' | 'decimal';

  // Typography
  font_family?: string;
  font_size?: number | string;
  font_weight?: number | string;
  font_style?: 'normal' | 'italic';

  // Color
  fill_color?: string;
  stroke_color?: string;
  stroke_width?: number;

  // Layout
  text_align?: 'left' | 'center' | 'right';
  vertical_align?: 'top' | 'middle' | 'bottom';
  line_height?: number;
  letter_spacing?: number;

  // Background plate
  background_color?: string;
  background_border_radius?: number;

  // Shadow
  shadow_color?: string;
  shadow_x?: number;
  shadow_y?: number;
  shadow_blur?: number;

  // Reveal
  mask?: TextMask;
}

Content#

FieldTypeDefaultDescription
textstring''Static text content. Optional when text_template is set.
text_templatestringTemplate with {{key}} placeholders that are substituted from vars every frame. Takes precedence over text when set.
spansTextSpan[]Inline-styled runs; takes precedence over both fields above. See Spans below.
varsRecord<string, number | string | Keyframe[]>Values substituted into the template. Keyframe[] values interpolate over time.
number_format'integer' | 'comma' | 'decimal''integer'How numeric vars are formatted. comma uses Intl.NumberFormat; integer floors; decimal keeps one place.

Animated number example#

{
  "type": "text",
  "text_template": "{{count}} views",
  "number_format": "comma",
  "vars": {
    "count": [
      { "time": 0,   "value": 0 },
      { "time": 1.5, "value": 8447 }
    ]
  }
}

The count animates from 0 to 8,447 across the first 1.5 seconds.

Spans#

Inline-styled runs for mixed styling within one element — a colored word, a highlighted phrase, exact line breaks. A span whose text is exactly "\n" is a hard line break. Each span inherits the element's typography and color unless it overrides them:

interface TextSpan {
  text: string;
  font_family?: string;
  font_size?: number | string;
  font_weight?: number | string;
  font_style?: 'normal' | 'italic';
  fill_color?: string;
  letter_spacing?: number;        // px tracking; inherits the element's
  background_color?: string;      // flat band behind the span
  background?: TextSpanBackground; // stylized band (height, inset, skew, radius)
  nowrap?: boolean;               // never word-wrap inside this span
}
{
  "type": "text",
  "font_size": 64,
  "spans": [
    { "text": "Ship it " },
    { "text": "today", "fill_color": "#FFD400", "nowrap": true },
    { "text": "." }
  ]
}

Typography#

FieldTypeDefaultDescription
font_familystring'sans-serif'CSS font-family. Web fonts must be loaded before render.
font_sizenumber | string48Pixels or CSS length string.
font_weightnumber | string'normal'100900 or named weight ('bold', 'black').
font_style'normal' | 'italic''normal'Italics.

Color#

FieldTypeDefaultDescription
fill_colorstring (hex)'#ffffff'Glyph fill.
stroke_colorstring (hex)Outline color. Pair with stroke_width.
stroke_widthnumber0Outline width in pixels.

Layout#

FieldTypeDefaultDescription
text_align'left' | 'center' | 'right''center'Horizontal alignment within the element box.
vertical_align'top' | 'middle' | 'bottom''middle'Vertical alignment within the element box.
line_heightnumber1.2Multiplier of font_size.
letter_spacingnumber0Pixels of tracking, added after every character including the last (Chrome's model). Spans inherit it unless they set their own.

Background plate#

A solid rectangle drawn behind the glyphs. Useful for highlight chips.

FieldTypeDefaultDescription
background_colorstring (hex)Plate fill. When unset, no plate is drawn.
background_border_radiusnumber0Plate corner radius in pixels.

Drop shadow#

FieldTypeDefaultDescription
shadow_colorstring (hex)Shadow color. When unset, no shadow.
shadow_xnumber0Horizontal offset in pixels.
shadow_ynumber0Vertical offset.
shadow_blurnumber0Blur radius.

Reveal mask#

Optional mask field for linear-wipe text reveal. Animatable via keyframe_animations on mask.progress.

interface TextMask {
  type: 'linear-wipe';
  angle?: number;
  progress?: number | Keyframe[];
  softness?: number;
}
FieldTypeDefaultDescription
type'linear-wipe'requiredMask type. Only linear-wipe is supported in v1.
anglenumber-45Wipe direction in degrees. 0 = left→right; -45 = bottom-left→top-right.
progressnumber | Keyframe[]1Reveal progress, 0..1. 0 = hidden, 1 = fully revealed. Animatable.
softnessnumber0.3Soft-edge width as a fraction of the bounding-box diagonal. Larger = softer wipe edge.

Example: animated text reveal#

{
  "type": "text",
  "text": "Hello, Clipkit.",
  "mask": { "type": "linear-wipe", "angle": -45 },
  "keyframe_animations": [
    {
      "property": "mask.progress",
      "keyframes": [
        { "time": 0,   "value": 0, "easing": "ease-out-quart" },
        { "time": 1.2, "value": 1 }
      ]
    }
  ]
}