View raw

text#

Static 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: "tok-str">'text';
  text?: string;          "tok-cmt">// use this OR spans, not both
  spans?: TextSpan[];

  "tok-cmt">// Typography
  font_family?: string;
  font_size?: number | string;        "tok-cmt">// px, CSS length, or "tok-str">'auto' to fit the box
  font_size_minimum?: number | string;
  font_size_maximum?: number | string;
  font_weight?: number | string;
  font_style?: "tok-str">'normal' | "tok-str">'italic';
  text_transform?: "tok-str">'none' | "tok-str">'uppercase' | "tok-str">'lowercase' | "tok-str">'capitalize';

  "tok-cmt">// Color
  fill_color?: string;
  gradient?: LinearGradient | RadialGradient | ConicGradient;        "tok-cmt">// overrides fill_color
  stroke_color?: string;
  stroke_width?: number;
  stroke_gradient?: LinearGradient | RadialGradient | ConicGradient; "tok-cmt">// overrides stroke_color
  stroke_align?: "tok-str">'center' | "tok-str">'outer' | "tok-str">'inner';                       "tok-cmt">// default "tok-str">'outer'

  "tok-cmt">// Layout
  text_align?: "tok-str">'left' | "tok-str">'center' | "tok-str">'right';
  vertical_align?: "tok-str">'top' | "tok-str">'middle' | "tok-str">'bottom';
  text_wrap?: boolean;
  x_padding?: number | string;
  y_padding?: number | string;
  x_alignment?: number | string;
  y_alignment?: number | string;
  line_height?: number;
  letter_spacing?: number;

  "tok-cmt">// Background band
  background_color?: string;
  background_border_radius?: number;
  background_padding?: number | [number, number];

  "tok-cmt">// Shadow
  text_shadow?: TextShadow | TextShadow[];

  "tok-cmt">// Reveal
  mask?: TextMask;
}

Content#

FieldTypeDefaultDescription
textstringThe text content. Use this or spans, not both.
spansTextSpan[]Rich-text runs with per-span styling; alternative to a single text string. See Spans below.

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?: "tok-str">'normal' | "tok-str">'italic';
  fill_color?: string;
  letter_spacing?: number;        "tok-cmt">// px tracking; inherits the element's
  background_color?: string;      "tok-cmt">// flat band behind the span
  background?: TextSpanBackground; "tok-cmt">// stylized band (height, inset, skew, radius)
  nowrap?: boolean;               "tok-cmt">// 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 | string48Font size in px, a CSS length string, or 'auto' to fit the box.
font_size_minimumnumber | string8Lower bound in px when font_size is 'auto'.
font_size_maximumnumber | string400Upper bound in px when font_size is 'auto'.
font_weightnumber | string'normal'100900 or named weight ('bold', 'black').
font_style'normal' | 'italic''normal'Italics.
text_transform'none' | 'uppercase' | 'lowercase' | 'capitalize''none'Case transform applied before layout.

Color#

FieldTypeDefaultDescription
fill_colorstring (hex)'#ffffff'Glyph fill.
gradientLinearGradient | RadialGradient | ConicGradientGradient fill (overrides fill_color). Geometric params (angle / rotation / cx / cy / radius) and stop offsets are keyframeable & expressionable — animate a stop offset for a colour wipe. Linear/radial/conic (conic is text-only).
stroke_colorstring (hex)Outline color. Pair with stroke_width.
stroke_widthnumber0Outline width in pixels.
stroke_gradientLinearGradient | RadialGradient | ConicGradientGradient stroke (overrides stroke_color); pair with stroke_width > 0. A conic stroke with rotation: { expr: "t*60" } = a rotating rainbow outline.
stroke_align'center' | 'outer' | 'inner''outer'Stroke position vs the glyph edge. outer keeps it outside the fill so it never eats the letterform.

Layout#

FieldTypeDefaultDescription
text_align'left' | 'center' | 'right''left'Horizontal text alignment within the element box.
vertical_align'top' | 'middle' | 'bottom''top'Vertical alignment within the element box.
text_wrapbooleantrueSoft-wrap within the box width. false forces a single line.
x_paddingnumber | string0Horizontal inset in px around the text.
y_paddingnumber | string0Vertical inset in px around the text.
x_alignmentnumber | stringFine horizontal alignment as a 0..1 fraction; overrides text_align.
y_alignmentnumber | stringFine vertical alignment as a 0..1 fraction; overrides vertical_align.
line_heightnumber1Line spacing as a multiple 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 band#

A band drawn behind the glyphs, shrink-wrapped per line. Useful for highlight chips.

FieldTypeDefaultDescription
background_colorstring (hex)Band fill. When unset, no band is drawn.
background_border_radiusnumber0Band corner radius in pixels.
background_paddingnumber | [number, number][0, 0]Band padding in px: a single number, or [x, y].

Drop shadow#

text_shadow is a per-glyph drop shadow: a single object, or an array of objects rendered back-to-front (last in the array is drawn on top). When unset, no shadow is drawn.

interface TextShadow {
  color: string;
  offset_x?: number;
  offset_y?: number;
  blur?: number;
  opacity?: number;
}
FieldTypeDefaultDescription
colorstring (hex)requiredShadow color.
offset_xnumber0Horizontal offset in pixels.
offset_ynumber0Vertical offset in pixels, positive = down.
blurnumber0Blur sigma in pixels (0 = crisp).
opacitynumber1Shadow opacity, 0..1.
{
  "type": "text",
  "text": "Stacked shadows",
  "text_shadow": [
    { "color": "#000000", "offset_y": 2, "blur": 4, "opacity": 0.6 },
    { "color": "#ff00aa", "offset_x": 4, "offset_y": 4 }
  ]
}

Reveal mask#

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

interface TextMask {
  type: "tok-str">'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-to-right; 90 = top-to-bottom; -45 = bottom-left→top-right.
progressnumber | Keyframe[]1Reveal amount, 0 (hidden) to 1 (fully shown). Animatable.
softnessnumber0.3Softness of the wipe edge, 0..1. Larger = softer.

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 }
      ]
    }
  ]
}