TextBlock
The textarea contract. The family's third input shape: not a flow you don't control (Prose), not an authored run (Text), but a plain multiline string the way a CMS field delivers it. Only the text prop is accepted, line breaks are honored, and sub-typography cannot be authored.
Sizes
preamble is the default voice — the standfirst, with its own leading. Three steps, md by default.
Size lg — a standfirst that leads the whole page.
Size md — the default standfirst, under a section heading.
Size sm — a short deck above a card group.
---
import TextBlock from "tsugite/TextBlock/TextBlock.astro";
---
{/* preamble is the default voice — the standfirst under a heading, with its
own leading. Three steps, md by default. */}
<TextBlock text="Size lg — a standfirst that leads the whole page." size="lg" />
<TextBlock text="Size md — the default standfirst, under a section heading." />
<TextBlock text="Size sm — a short deck above a card group." size="sm" />Body voice
For a plain field that is not a standfirst. One door per look and input: an authored single-run body text is Text; a body-voiced block from a plain field is TextBlock. Child content is the one thing a field cannot be, and the table refuses it.
Body lg — a description field, read at the large step.
Body md — the everyday description field.
Body sm — a footnote field, or the fine print.
---
import TextBlock from "tsugite/TextBlock/TextBlock.astro";
---
{/* The body voice, for a plain field that is not a standfirst. One door per
look: an authored single-run body text is Text; a body-voiced BLOCK from
a plain field is TextBlock. */}
<TextBlock voice="body" text="Body lg — a description field, read at the large step." size="lg" />
<TextBlock voice="body" text="Body md — the everyday description field." />
<TextBlock voice="body" text="Body sm — a footnote field, or the fine print." size="sm" />The multiline contract
Line breaks in the string survive as line breaks; runs of spaces collapse. This is what the component exists for.
Opening hours Monday to Friday 9–17 Saturday 10–14 Closed on Sundays and public holidays.
---
import TextBlock from "tsugite/TextBlock/TextBlock.astro";
// The string a CMS textarea delivers: \n for line breaks, runs of spaces
// where the editor left them. white-space: pre-line keeps the breaks and
// collapses the spaces.
const fromTheField =
"Opening hours\nMonday to Friday 9–17\nSaturday 10–14\nClosed on Sundays and public holidays.";
---
<TextBlock voice="body" text={fromTheField} />Markup stays literal
Sub-typography is unrepresentable. Tags and entities in the string are escaped and shown as text — the field is plain, and stays plain.
You cannot <strong>bold</strong> a word here, & entities stay literal.
---
import TextBlock from "tsugite/TextBlock/TextBlock.astro";
// Sub-typography is unrepresentable: markup in the string is escaped and
// shows as text. The field is plain, and stays plain.
const attempted = "You cannot <strong>bold</strong> a word here, & entities stay literal.";
---
<TextBlock voice="body" text={attempted} />Alignment and wrapping
align-inline sets the inline alignment with logical values, start | center | end; wrap chooses the line-breaking strategy, pretty by default.
A centered standfirst, balanced so its two lines come out even when the space runs out
Right-aligned, wrapping pretty by default, so no single word is left on the last line
---
import TextBlock from "tsugite/TextBlock/TextBlock.astro";
---
{/* align: left | center | right. wrap: pretty (default) | balance | stable — no nowrap: the field's own line breaks are the contract.
A centered standfirst is the natural case — balance it so the lines
come out even. */}
<TextBlock text="A centered standfirst, balanced so its two lines come out even when the space runs out" alignInline="center" wrap="balance" />
<TextBlock text="Right-aligned, wrapping pretty by default, so no single word is left on the last line" alignInline="end" />Line length
The standfirst is capped at the preamble stop's line length, on by default (ADR-0021); capInline={false} releases it.
A standfirst is read in one breath, so its measure is shorter than the body's: fifty-six characters of the preamble face at this size.
With the ceiling off the standfirst runs the whole column.
---
import TextBlock from "tsugite/TextBlock/TextBlock.astro";
---
{/* The standfirst is capped at the preamble stop's line length (56ch at md), on by default. */}
<TextBlock text="A standfirst is read in one breath, so its measure is shorter than the body's: fifty-six characters of the preamble face at this size." />
<TextBlock capInline={false} text="With the ceiling off the standfirst runs the whole column." />Test bench
The TextBlock fixture — the preamble steps and the multiline specimen, mounted unchanged.
TextBlock
The third input shape: not a flow (Prose), not an authored run (Text) — a plain multiline string the way a textarea delivers it. Only the text prop is accepted; child content is a dev-visible error, so sub-typography cannot be authored.
voice: preamble
the standfirst voice — own leading (1.35) · size lg–sm
| p | |
|---|---|
| size lg | The preamble lg — a standfirst that earns its own voice. |
| size md | The preamble md — a standfirst that earns its own voice. |
| size sm | The preamble sm — a standfirst that earns its own voice. |
the multiline contract
line breaks respected, spaces collapse — variant body
| pre-line | First line, straight from a CMS textarea. Second line — the break above is a \n, not markup. Third line proves pre-line holds. |
|---|