Skip to content

Text

Body-copy primitive with responsive size, weight, alignment, role variants, and truncation.

  • stable
  • since v0.1.0
  • 4.26 kB
  • typography
  • primitive

Renders a <span> via Box by default; switch to p, div, label, strong, or em through the as prop so the document outline stays semantic.

Preview
Open
tsx

Five body sizes are available — xs, sm, md (default), lg, and xl — each pulling family, font-size, and line-height from the matching body composite tokens.

Preview
Open
tsx

Pick from regular, medium, semibold, and bold to shift emphasis without changing scale.

Preview
Open
tsx

variant layers a role on top of size: caption for de-emphasised metadata, overline for uppercase eyebrow labels, and lead for relaxed lead-in paragraphs. The default body variant leaves typography untouched.

Preview
Open
tsx

Combine italic, underline, and strikethrough to style inline runs. decorationColor recolours underline and strikethrough independently from the text colour.

Preview
Open
tsx

Pass truncate as a boolean for single-line ellipsis or a number greater than one for multi-line clamp.

Preview
Open
tsx

Swap the rendered element with as (span, p, div, label, strong, em) so semantics match the surrounding flow without losing styling.

Preview
Open
tsx
PropTypeDefaultDescription
size
Responsive<TextSize>
Body type scale step. Maps to the `body.*` composite typography tokens.
weight
Responsive<TextWeight>
Font-weight token. Resolves to the matching `font-weight-*` CSS variable.
align
Responsive<TextAlign>
Horizontal text alignment.
variant
"body"|"caption"|"overline"|"lead"
Semantic role atop the base size — e.g. `caption`, `overline`, `lead`.
truncate
number|boolean
`true` → single-line truncation; `number > 1` → multi-line line-clamp.
italic
boolean
Renders italic glyphs via `font-style: italic`.
underline
boolean
Draws a `text-decoration: underline` line.
strikethrough
boolean
Draws a `text-decoration: line-through` line.
decorationColor
"bg.canvas"|"bg.surface"|"bg.subtle"|"bg.muted"|"bg.raised"|"bg.overlay"|"bg.inverse"|"fg.subtle"|"fg.muted"|"fg.inverse"|"fg.default"|"fg.disabled"|"fg.onAccent"|"border.subtle"|"border.default"|"border.disabled"|"border.strong"|"border.focus"|"accent.solid"|"accent.solidHover"|"accent.solidActive"|"accent.soft"|"accent.softHover"|"accent.softActive"|"accent.ring"|"accent.onSolid"|"feedback.success.foreground"|"feedback.success.border"|"feedback.success.solid"|"feedback.success.soft"|"feedback.success.onSolid"|"feedback.danger.foreground"|"feedback.danger.border"|"feedback.danger.solid"|"feedback.danger.soft"|"feedback.danger.onSolid"|"feedback.warning.foreground"|"feedback.warning.border"|"feedback.warning.solid"|"feedback.warning.soft"|"feedback.warning.onSolid"|"feedback.info.foreground"|"feedback.info.border"|"feedback.info.solid"|"feedback.info.soft"|"feedback.info.onSolid"
Colour for `underline` / `strikethrough` decorations.
className
string
Additional class names appended after Cynosure's base classes.
style
CSSProperties
Inline style overrides merged last; wins over Cynosure-computed style.
children
ReactNode
Rendered content.
padding
Padding on all four sides. Token from the spacing scale.
paddingX
Horizontal padding (left + right). Overrides `padding` on the X axis.
paddingY
Vertical padding (top + bottom). Overrides `padding` on the Y axis.
paddingTop
Padding on the top edge. Beats `padding` / `paddingY`.
paddingRight
Padding on the right (inline-end in RTL) edge.
paddingBottom
Padding on the bottom edge.
paddingLeft
Padding on the left (inline-start in RTL) edge.
margin
Margin on all four sides. Accepts the spacing scale or `"auto"`.
marginX
Horizontal margin (left + right). Use `"auto"` to centre.
marginY
Vertical margin (top + bottom).
marginTop
Margin on the top edge.
marginRight
Margin on the right edge.
marginBottom
Margin on the bottom edge.
marginLeft
Margin on the left edge.
width
Element width. Accepts a `SpaceToken`, `LengthValue`, or named alias.
height
Element height. Accepts a `SpaceToken`, `LengthValue`, or named alias.
minWidth
Minimum width — useful for preventing flex children from collapsing.
maxWidth
Maximum width — `"prose"` caps to a comfortable reading measure.
minHeight
Minimum height.
maxHeight
Maximum height.
background
Background colour. Use a `ColorToken` like `"bg.surface"` for theme awareness.
color
Text colour. Inherits unless set.
borderColor
Border colour. Pair with `borderWidth` to make the border visible.
borderWidth
Border thickness in scale steps.
borderStyle
Border line style.
borderRadius
Corner rounding token.
boxShadow
Drop-shadow token from the elevation scale.
opacity
Responsive<number | `${number}`>
Opacity 0–1. Use sparingly — prefer surface tokens over translucency.
overflow
How content that exceeds the box is handled.
overflowX
Horizontal-axis overflow control. Overrides `overflow` for the X axis.
overflowY
Vertical-axis overflow control.
display
CSS `display` value. `"contents"` removes the element's box from layout.
position
CSS `position`. Pair with `top`/`right`/`bottom`/`left` for placement.
top
Top inset (when positioned). Accepts a `SpaceToken`, `"auto"`, `"0"`, or `LengthValue`.
right
Right inset (when positioned).
bottom
Bottom inset (when positioned).
left
Left inset (when positioned).
zIndex
Stacking-context layer token (`"modal"`, `"tooltip"`, …).
gridColumn
Responsive<string>
Grid-column shorthand (e.g. `"1 / 3"`, `"span 2"`).
gridRow
Responsive<string>
Grid-row shorthand.
gridArea
Responsive<string>
Named grid area.
flex
Responsive<"1" | "none" | "auto" | "initial" | (string & {})>
Shorthand: `1 | auto | none | initial | <css>`. Resolves to `flex` on the child.
flexGrow
Responsive<number | `${number}`>
Grow factor inside a flex container.
flexShrink
Responsive<number | `${number}`>
Shrink factor inside a flex container.
flexBasis
Responsive<"content" | SizeValue>
Initial main-axis size before grow/shrink.
alignSelf
Override `align-items` for a single child.
justifySelf
Override `justify-items` for a single child (grid).
order
Responsive<number | `${number}`>
Flex/grid child reorder index.
asChild
boolean
When `true`, renders the primitive's single React child via `Slot`, forwarding className/style/ref/event handlers onto it.
as
"strong"|"span"|"p"|"div"|"label"|"em"
"span"
Rendered intrinsic element. Restricted to inline-friendly tags.
  • Choose the rendered element via as so the document outline stays meaningful — use p for paragraphs, span for inline runs, label only inside form contexts.
  • Avoid Text where a heading belongs; reach for the Heading component when content introduces a section.
  • Keep size + weight combinations above the platform contrast minimum; variant="caption" and variant="lead" use the muted foreground token and should stay on backgrounds that preserve contrast.
  • truncate hides overflow visually only — supply the full string in the DOM (or title) so assistive tech still receives the complete content.
  • Pair Text with Heading to build a readable title-and-body grouping.
  • Use variant="overline" with size="xs" for tight section eyebrows above a Heading.
  • Drop asChild onto a framework link to project Text’s typography onto a routed element without an extra wrapper.
  • For long-form prose, constrain the parent width so line length stays readable.