Text

Wrap a word or a heading in <sd-text> and it becomes a solid: extruded letters in your own font, drawn exactly over the HTML, which stays in the page for layout and screen readers.

Solids

How text works

The element reads the text it wraps and the computed CSS font of that element, rasterizes the line on a canvas, turns the raster into a signed distance field and uploads it as a texture. The shader extrudes that field with a rounded edge and marches it like any object, so the letters take every shade, effect and animation, and every interaction moves them. Tap a letter with poke and the word turns to show its sides. With pixel the raster is sampled at that cell size, which gives a pixel font from any monospace; the distance field keeps the blocks sharp.

On a light background the word reads through its shade like any object: auto is glass in the dark theme and matte in the light one, with a darker edge; no effect is needed.

Options

AttributeTypeDefaultRangeDescription
depthnumber0.350.02 to 1Half the thickness of the extrusion.
bevelnumber0.250 to 1Rounding of the edges.
pixelnumber00 to 24Raster cell in px for a pixel-font look from any monospace; 0 keeps the glyphs smooth.
colorcolor#9bd1ffany CSS color, including color(display-p3 r g b)Accent color of the object.
animationlistnoneidle, spin, pulse, breathe, floatSpace separated animations, composed in order.
speednumber10.1 to 3Multiplies animation time.
statekeywordidleoff, idle, busy, activeBrightness level, eased on change.
effectlistnoneglow, beam, rgb-split, pixelate, dither, scanlines, halftone, outline, grain, vignette, chroma, ripple, defocusSpace separated post effects on this object only.
shadingkeywordautoauto, glass, matte, cel, clay, metalHow the surface takes light. auto is glass in the dark theme and matte in the light one; a scene's shading is the default for its children.
gravitykeywordorbitcenter, orbit, fall, noneRole in a gravity scene.

License

MIT. Use it anywhere, credit appreciated.