Skip to content

API & OpenType reference

slabify(el, { min = 8, max = 1200, lineHeight = 0.88, refine = true, mode = 'auto' });
slabAll(selector = '[data-slab]', opts); // every matching element

slabify canvas-measures the text, packs words into lines of equal width, sizes each line to fill the measure, gates on document.fonts.ready, reflows under ResizeObserver (width-guarded so it can’t loop), keeps the real text for accessibility, and honors text-transform.

OptionDefaultMeaning
min / max8 / 1200font-size clamp (px), so one long word can’t blow the layout
lineHeight0.88line-height for the stacked slab lines
refinetruebinary-search each line against real rendered metrics for sub-pixel-flush edges
mode'auto''auto' prefers the width axis and falls back to font-size; force with 'width' or 'size'
micro(selector = '[data-micro]', { quotes = true, hang = true });

Pulls a leading quote into the margin so the text edge is optically flush, and curls straight quotes. No-ops where the browser hangs punctuation natively (Safari). Entirely optional.

ClassFor
htbase layer (kerning, ligatures, optical sizing, balanced headings, measure) on a wrapper
ht-tnum / ht-datatabular figures / tabular + slashed zero
ht-onum / ht-lnumoldstyle / lining figures
ht-zeroslashed zero
ht-smallcapstrue small caps
ht-capsALL-CAPS with case-sensitive forms + tracking
ht-fracdiagonal fractions (scope tightly)
ht-justifyjustified body copy with hyphenation (needs a lang attribute)
ht-dropcap / ht-hangdrop cap / hanging punctuation
ht-measure / ht-displayreadable measure cap / fluid display size

Prefer the mapped CSS property over raw font-variation-settings, which sets all axes at once and bypasses the cascade.

AxisMapped property
wghtfont-weight
wdthfont-stretch
slntfont-style: oblique <deg>
italfont-style: italic
opszfont-optical-sizing: auto
GRADfont-variation-settings: "GRAD" <n> (weight without reflow)

hypertype.css gates each progressive-enhancement feature behind @supports with a fallback, so the CSS-only subset is safe everywhere.

FeatureChromiumSafariFirefoxPosture
text-wrap: balance114+17.5+121+ship unconditionally
text-wrap: pretty117+17.5+noenhancement; FF wraps normally
text-box-trim133+18.2+nogate; fall back to padding
initial-letter110+yes (-webkit-)nogate; fall back to float drop cap
hanging-punctuationno10+noSafari-only; micro.js covers the rest
hyphens: auto88+yes43+safe with a lang attribute
font-optical-sizing79+14+62+production-safe
font-variant-*52+9.1+34+production-safe

The full OpenType tag catalog (high-level vs low-level mapping, stylistic sets, swashes, the must-use-the-raw-tag cases), the slab algorithm, and the borrow-vs-reject notes on existing tools are in docs/REFERENCE.md.