Example#
Built to be tested
Usage#
Use a fitted line for one short display line that should fill its slot exactly: a poster word, a stat in a card, a splash title. The first paint uses the CSS clamp and a server estimate, so nothing jumps; the client fitter then sets the exact size, and the reserved height never changes.
- One line, a few words. Display voices carry three words at most (D-D3); headings that wrap are
PageHeroorSectionHead. - Below its floor. If the words cannot fit at the role's floor, the fitter goes smaller rather than wrapping or spilling, and warns in development.
- Readers' text spacing (WCAG 1.4.12) makes it refit, so a reader's settings never push it out of its box.
Anatomy#
Built to be tested
- SlotReserves its height from the first paint.
.mk-fitted-line - WordsSized to fill the slot's width.
.mk-fitted-line-ink
Volume#
The fitter is reading layer; the display role it sizes grows weight and scale from Press, and the line refits to match.
Quiet
Built to be tested
Studio
Built to be tested
Press
Built to be tested
Rave
Built to be tested
Content#
- Three words or fewer, the kind of line that works on a poster: "Built to be tested".
- Never a sentence with a full stop in the middle.
Do and don't#
Do
Built to be tested
Don't
Every website we build is tested on real phones before launch
Accessibility#
- The words are ordinary text in the element you render (
<h1 />for a page title). - Fitting only shrinks the words inside the height the first paint reserved, so there is no layout shift.
- A non-standard voice holds at most three words (D-D3); a dev warning says so.
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
children required | string | none | The words (a non-standard voice holds at most 3, D-D3). |
typeRole | FittedRole | display | The type role (default `display`). Named `typeRole`, never `role`, so it cannot read as an ARIA role (D-N79). |
voice | "condensed" | "standard" | "wide" | none | |
maxLines | 1 | 2 | 3 | 1 | Lines the slot allows (default 1). |
estimate | number | none | The line's width in em at its role and voice (`fitEm(text, typeRole, voice)` from `@maxgrits/overprint-react/art`, on the server): one-line slots then print the estimated fit on first paint, before hydration. P1. |
render | RenderProp | <span> | Default `<span>`; a page title passes `<h1 />`. |
className | string | none | |
style | CSSProperties | none |
Tokens#
System tokens (3)
Its own properties (2)
--mk-fit-em--mk-fit-size
Changelog#
Arrived in 0.1.0.
- Type: the server advance table (
anybodyWidthEm,fitEm,estimateFit,FIT_CUTSin./art), which sizes SFX bursts within 1.5 % of the browser and givesFittedLineanestimatefor its first paint. Read the whole entry
Sectionwith its plate andArtslot,Plate,VolumeScope,PageHero,SectionHead,Eyebrow,Card,LineCard,InfoPanel,Stack,Cluster,Grid,Container,Main,Ruleand theFittedLineclient fitter;Navbarwith theNavDisclosuremega panels,Footer,FooterMap,BuildStamp,SkipLink,ActionDockandVisitorControls; theTableparts,ComparisonTablewith the one-tier switcher,SpecStrip,Numeral,Stat,StatGroup,StatusChip,BadgeandScoreDial;ProsewithmdxComponents,Quote,CodeBlockwithCopyButton,Figure,ScreenshotFrameandPhoneFrame; and the brand: the three evolved 2 × 2 options inmarkGeometry(a Overprint by default, b Paper seam, c Key block) with the pixel-snappedpxmode and the one-ink seam variant,logoGeometrywith the 1x clear-space frame,Mark,Wordmark,Logo,MaxosMarkandLineBadge. Read the whole entry- FittedLine refits when its words' box changes (a reader's text spacing), goes below its role's floor before it wraps, and never spills. Read the whole entry