Overview
Text provides typography and overflow handling. It renders a div by default. Omit size, weight and color to keep inheriting typography from its surroundings.
Usage
Give the text a constrained width, then settruncate to show an ellipsis when it overflows:
Choose typography
size uses the existing theme scale. It changes font size, with no height, font-family or line-height default:
weight accepts regular (400), medium (500) or semibold (600). color accepts primary, secondary, tertiary or light. Each omitted prop inherits independently. The visual size does not change the semantic element.
For captions, compose the small size, semibold weight and light color:
style for runtime colors and parent-layout constraints. Caller classes and render composition target the same text element. Text adds no typography defaults when these props are omitted.
Limit the number of lines
UselineClamp with a positive integer. Choose either truncate or lineClamp; their props are mutually exclusive.
Choose an element
Userender when the text needs another semantic element:
Props
Native attributes, children, refs, class names, and styles target the rendered text element.TextProps is exported from twenty-ui/primitives/typography. Text content is rendered unchanged, including caller-provided links.
"light" | "primary" | "secondary" | "tertiary"
Semantic text color. Omitted values inherit; native style supports runtime colors.
number
Positive integer limiting the number of visible lines. Cannot be combined with
truncate.ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>
Replaces the default div. Native props and the ref target the rendered text element.
"lg" | "md" | "sm" | "xl" | "xs" | "xxl" | "xxs"
Font size from the theme scale. Omitted values inherit; this does not set height.
boolean
Truncates one line with an ellipsis. Cannot be combined with
lineClamp."medium" | "regular" | "semibold"
Theme font weight. Omitted values inherit.
Migration
color now selects a semantic theme color. Move arbitrary CSS color values from a native color attribute to style={{ color: customColor }}. Existing styles, classes and render composition continue to target the text element.