Skip to content

Text

⋯

Text applies Nesra’s typography roles to a chosen HTML element. The visual role does not choose the heading level for the document.

import { Text } from "@nesra/ui/text";
export function Description() {
return (
<section>
<Text as="h2" variant="heading3">
Account details
</Text>
<Text>Review the information before saving.</Text>
</section>
);
}

Text is also exported from @nesra/ui.

Typography lists the exact metrics.

Account details

Lead copy

Default product copy

Compact metadata

Section heading

A long supporting label that stays on one line in this narrow container

Text sets typography only and inherits its color, so it follows whatever text role its container uses in either mode. Set a color with a text role such as text-nesra-text-body or text-nesra-text-support. The text-nesra-text-muted alias was removed in 1.0; see Upgrading to 1.0.

Choose as from the document structure. For example, a visually smaller section heading can use as="h2" with variant="heading3". Heading variants require an explicit as value. A default body Text renders <p>. truncate clips a single line visually, so make essential content available in full elsewhere on the page.

Prop Type Default Description
variant TextVariant body Selects the visual role.
size large | medium | small | xsmall medium Body size. Unavailable for headings.
weight semibold | medium | regular regular Body weight. Unavailable for headings.
as TextElement p for body Required for heading variants.
truncate boolean false Adds single-line ellipsis behavior.
className string — Adds or overrides classes through Nesra’s class merger.

Native text element attributes and refs are forwarded. See Typography for exact type metrics and font-loading responsibilities.

TextVariant is body, heading1, heading2, heading3, heading4, heading5, or heading6. TextElement is h1, h2, h3, h4, h5, h6, p, span, label, dt, dd, li, figcaption, legend, em, strong, small, abbr, or time.