Typography
@xui/textTypographic styling for a heading element.
Install
pnpm add @xui/text Add the barrel to a standalone component's imports:
import { XuiTextImports } from '@xui/text';@Component({ imports: [XuiTextImports], // …})Examples
Default
Loading preview…
<p xuiText [ellipsize]="false">The quick brown fox jumps over the lazy dog.</p>Headings
Loading preview…
<div class="flex flex-col gap-3"> <h1 xuiHeading>Heading level 1</h1> <h2 xuiHeading>Heading level 2</h2> <h3 xuiHeading>Heading level 3</h3> <h4 xuiHeading>Heading level 4</h4> <h5 xuiHeading>Heading level 5</h5> <h6 xuiHeading>Heading level 6</h6> <h2 xuiHeading [level]="5">Still an h2 in the outline, sized like an h5</h2></div>Colors
Loading preview…
<div class="flex flex-col gap-1"> <p xuiText color="default">default — primary body copy</p> <p xuiText color="muted">muted — secondary copy</p> <p xuiText color="subtle">subtle — hints and placeholders</p> <p xuiText color="primary">primary</p> <p xuiText color="success">success</p> <p xuiText color="error">error</p> <p xuiText color="warning">warning</p> <p xuiText color="info">info</p></div>Ellipsize
Loading preview…
<div class="flex flex-col gap-3"> <div class="border-border w-48 rounded border p-2"> <span xuiText ellipsize>Short enough</span> </div> <div class="border-border w-48 rounded border p-2"> <span xuiText ellipsize>A considerably longer value that will not fit inside this box</span> </div></div>Html elements
Loading preview…
<div class="flex max-w-prose flex-col gap-2"> <p xuiText>Install it with <code xuiCode>pnpm i @xui/text</code>, then import the directives.</p> <blockquote xuiBlockquote> A directive on the native element keeps the semantics in the markup. </blockquote> <pre xuiCodeBlock><code><h1 xuiHeading>Title</h1><p xuiText color="muted">Body</p></code></pre> <ul xuiList> <li>Unordered item</li> <li> Nested list <ul xuiList> <li>Inner item</li> </ul> </li> </ul> <ol xuiList> <li>Ordered item</li> <li>Second item</li> </ol> </div>API
XuiHeading
h1[xuiHeading],h2[xuiHeading],h3[xuiHeading],h4[xuiHeading],h5[xuiHeading],h6[xuiHeading]Typographic styling for a heading element.
Variants
level1Inputs
classClassValueThe user-defined classes. Merged last so they win over the variant classes.''levelXuiHeadingLevel | nullOverrides the visual size. Defaults to the host element's own level.nullTypographic styling for the plain HTML elements prose is made of — blockquote, code, pre, and ordered and unordered lists.
Inputs
classClassValueThe user-defined classes. Merged last so they win over the base classes.''Styles a native <blockquote> as quoted prose.
Styles a native inline <code>.
Styles a native <pre> as a code block.
Styles a native <ol> or <ul>, including nested ones.
Body text with optional truncation.
Variants
colorsizeweightellipsizefalseInputs
classClassValueThe user-defined classes. Merged last so they win over the variant classes.''colorXuiTextVariants['color']Semantic text colour, from foreground down to subtle plus the intent colours.this.config.colorsizeXuiTextVariants['size']Font size, from the theme's type scale.this.config.sizeweightXuiTextVariants['weight']Font weight.this.config.weightellipsizebooleanTruncate with an ellipsis instead of wrapping.falsetitlestring | nullAn explicit title, which always wins over the generated overflow title.nullMethods
remeasure(): voidRe-check whether the content overflows. Called automatically when the element resizes. Call it yourself after changing the text inside a box whose size did not change — measuring on every render instead would mean a scrollWidth read per instance per change detection cycle, which is exactly the reflow cost that makes long lists slow.