Luke UI
GitHub repository

Text

Styled text with semantic typography styles and colour roles.

Text applies Luke UI typography without adding heading semantics. It needs a Luke UI theme root. See Getting started.

Text — Basic
The quick brown fox jumps over the lazy dog.

Element type

Text renders React Aria's Text component, which uses a span by default. Set elementType to choose a semantic element without changing the type treatment. Text trims Capsize space on known block elements such as p, div, headings, and blockquote, and skips it for inline or unknown element types.

<Text elementType="p">A paragraph of supporting copy.</Text>

<Text elementType="label">Email address</Text>

Typography

Pass typography to choose a style. body is the default. See Typography for the full style reference.

Text — Lead typography
Lead text sits at a larger size than body text.

Set fontWeight only when you need to override the style's weight. Themes expose body, label, heading, and emphasis roles for that purpose.

Alignment

Set textAlign when the layout needs a different inline alignment.

Text — Alignment

Start aligned

Centre aligned

End aligned

Numeric glyphs

Use fontVariantNumeric to align numeric columns, format fractions and ordinals, or distinguish zero with a slash.

Text — Numeric glyphs
Tabular
111,111 888,888
Fractions
1/2 3/4 5/6
Ordinals
1st 2nd 3rd 4th
Slashed zero
012 OQR

Trimming

Block text trims space above capitals and below the baseline by default. That makes vertical spacing more predictable in cards and other bounded layouts. Inline text skips trim so its pseudo-elements cannot interrupt the surrounding line. Set shouldDisableTrim explicitly when you need to override the element-type inference.

Text — Trimming
Aa

Truncation

Use lineClamp to constrain text to one line or up to five lines. Text truncates overflow with an ellipsis. It disables trimming automatically when you set lineClamp.

Text — Truncation
Short lines are easier to scan than long ones, which is why well-set text rarely stretches edge to edge on a wide screen, no matter how much room is available.
Short lines are easier to scan than long ones, which is why well-set text rarely stretches edge to edge on a wide screen, no matter how much room is available.

Transform and decoration

Use textTransform and textDecoration when the content calls for them. These props affect the rendered text only, so avoid using uppercase styling as a substitute for a clear label.

Text — Transform and decoration
Uppercase textUnderlined text

Use Heading for a section heading. It manages heading levels for you. Use Text with a larger style such as display or heading1 for prominent content that is not a heading. A large status value is one example.

Use Numeral to format locale-aware numbers and Emoji for an emoji with a reliable accessible label.

API

TextProps also accepts compatible DOM and ARIA attributes and event handlers for its rendered element.

Prop

Type