Text

Alignment target:@astryxdesign/core v0.7.1 · Text

Body text is for reading.
<Text
  type="body"
  color="primary"
  weight="regular"
>
  Body text is for reading.
</Text>

Props #

NameTypeDefaultDescription
typeTextType'body'Semantic text type. Determines default size, weight, and line-height. Optional: body, large, label, supporting, code, display-1, display-2, display-3.
sizeTextSize-Explicit font size override. Optional: sm, md, lg, xl.
colorTextColor'primary'Text color. Optional: primary, secondary, accent, disabled, placeholder, inherit.
weightTextWeight-Font weight override. Optional: regular, normal, medium, semibold, bold. normal is the same weight as regular.
textWrapTextWrap-Wrapping behavior: wrap, nowrap, balance, or pretty.
wordBreakTextWordBreak-How a long unbroken string breaks when truncating: normal, break-word, or break-all. Without truncation, a token longer than its line (a URL, an ID) wraps (overflow-wrap: break-word), so in ordinary flow the text does not make the page scroll sideways. Inside a flex row, give the flex child min-width: 0 so it can shrink. A container you style with overflow-wrap: anywhere does not reach this text; Astryx's own containers pass their wrap through.
hasCapsizebooleanfalseTrims the leading above the cap height and below the baseline with text-box-trim, so glyphs sit flush with the box edges. Forces block layout.
hasStrikethroughbooleanfalseDraws a line through the text.
hasTabularNumbersbooleanfalseUses tabular figures so digits line up across rows.
displayTextDisplay'inline'Display type: inline or block.
asTextAs'span'HTML element to render. Optional: span, p, div, label, h1, h2, h3, h4, h5, h6. Heading tags render a real heading element but keep Text typography; use Heading for heading sizing.
justify'start' | 'center' | 'end''start'Text alignment. start and end follow the writing direction.
hasTruncateTooltipboolean | 'above' | 'below' | 'start' | 'end'truePuts the full text in a tooltip after truncation. false turns it off and skips the measurement. It stays closed when the text fits. The tooltip mounts on the first hover, tap or keyboard focus; until then the element has no tooltip layer and no aria-describedby.
maxLinesnumber0Maximum lines before truncation. 0 means no truncation. A positive value forces block layout so the ellipsis has a width.

Native attributes #

The root element is determined by as, defaulting to <span>.

The following are passed to the root element:

  • HTML attributes.
  • aria-* attributes.
  • data-* attributes.
  • class.
  • style.