Skip to content

Text

Text

Text in the Wave type ramp. Renders a <span> by default; as renders any element with correctly typed props (<Text as="h1" variant="title-1">, <Text as="label" htmlFor="…">).

Text sets no color: it inherits the surrounding color (the provider's foreground by default), so it follows the theme. Add a color with className (text-muted-foreground); the variant stays applied.

Examples

Default

The quick brown fox jumps over the lazy dog.
export const Default: Story = {};

Variants

caption-2caption-1body-1body-2subtitle-2subtitle-1title-3title-2title-1large-titledisplay
export const Variants: Story = {
  argTypes: {
    variant: { control: false },
  },
  render: (args) => (
    <div className="flex flex-col gap-2">
      {variants.map((variant) => (
        <Text key={variant} {...args} variant={variant}>
          {variant}
        </Text>
      ))}
    </div>
  ),
};

Weights

RegularMediumSemiboldBold
export const Weights: Story = {
  argTypes: {
    weight: { control: false },
  },
  render: (args) => (
    <div className="flex flex-col gap-2">
      <Text {...args} weight="regular">
        Regular
      </Text>
      <Text {...args} weight="medium">
        Medium
      </Text>
      <Text {...args} weight="semibold">
        Semibold
      </Text>
      <Text {...args} weight="bold">
        Bold
      </Text>
    </div>
  ),
};

Fonts and weights

base regular: 0123456789 const total = 1,234.56;base medium: 0123456789 const total = 1,234.56;base semibold: 0123456789 const total = 1,234.56;base bold: 0123456789 const total = 1,234.56;
monospace regular: 0123456789 const total = 1,234.56;monospace medium: 0123456789 const total = 1,234.56;monospace semibold: 0123456789 const total = 1,234.56;monospace bold: 0123456789 const total = 1,234.56;
numeric regular: 0123456789 const total = 1,234.56;numeric medium: 0123456789 const total = 1,234.56;numeric semibold: 0123456789 const total = 1,234.56;numeric bold: 0123456789 const total = 1,234.56;
export const FontsAndWeights: Story = {
  name: 'Fonts and weights',
  argTypes: {
    font: { control: false },
    weight: { control: false },
  },
  render: (args) => (
    <div className="flex flex-col gap-4">
      {(['base', 'monospace', 'numeric'] as const).map((font) => (
        <div key={font} className="flex flex-col gap-1">
          {(['regular', 'medium', 'semibold', 'bold'] as const).map((weight) => (
            <Text key={weight} {...args} font={font} weight={weight}>
              {font} {weight}: 0123456789 const total = 1,234.56;
            </Text>
          ))}
        </div>
      ))}
    </div>
  ),
};

Layout and decoration

A long line that is cut with an ellipsis where the box ends.One line that does not wrap and runs out of its box.Centered in a blockAligned to the endItalicUnderlineStrikethroughUnderline and strikethrough
export const LayoutAndDecoration: Story = {
  name: 'Layout and decoration',
  argTypes: {
    truncate: { control: false },
    wrap: { control: false },
    align: { control: false },
  },
  render: (args) => (
    <div className="flex w-72 flex-col gap-3">
      <Text {...args} truncate>
        A long line that is cut with an ellipsis where the box ends.
      </Text>
      <Text {...args} wrap={false}>
        One line that does not wrap and runs out of its box.
      </Text>
      <Text {...args} block align="center">
        Centered in a block
      </Text>
      <Text {...args} block align="end">
        Aligned to the end
      </Text>
      <Text {...args} italic>
        Italic
      </Text>
      <Text {...args} underline>
        Underline
      </Text>
      <Text {...args} strikethrough>
        Strikethrough
      </Text>
      <Text {...args} underline strikethrough>
        Underline and strikethrough
      </Text>
    </div>
  ),
};

Muted Caption

Last saved 2 minutes ago
export const MutedCaption: Story = {
  args: {
    variant: 'caption-1',
    className: 'text-wave-muted-foreground',
    children: 'Last saved 2 minutes ago',
  },
};

As Heading

Page heading

export const AsHeading: HeadingStory = {
  args: {
    as: 'h1',
    children: 'Page heading',
    variant: 'title-1',
    weight: 'bold',
  },
};

Props

NameTypeRequiredDefaultDescription
variant'caption-2' | 'caption-1' | 'body-1' | 'body-2' | 'subtitle-2' | 'subtitle-1' | 'title-3' | 'title-2' | 'title-1' | 'large-title' | 'display'No'body-1'

Typography variant controlling font size and line height (the Wave type ramp).

weight'regular' | 'medium' | 'semibold' | 'bold'No

Font weight: 'regular', 'medium', 'semibold' or 'bold'. Unset, the variant's own weight applies: semibold for 'subtitle-2' and every larger variant ('subtitle-1', the titles, 'large-title', 'display'), inherited for the caption and body variants. Pass 'regular' for a title at regular weight.

font'base' | 'monospace' | 'numeric'No'base'

Font family: 'base' keeps the inherited family (the Wave sans-serif), 'monospace' sets the Wave monospace stack for code and identifiers, 'numeric' the stack for figures that should align in columns. Fluent's font prop. A className that sets a font family replaces it.

wrapbooleanNotrue

Whether the text wraps. false keeps it on one line (white-space: nowrap), and a line longer than its box then overflows it; add truncate to cut it with an ellipsis. Fluent's wrap.

truncatebooleanNo

Cuts a line that does not fit its box with an ellipsis. It keeps the text on one line (as wrap={false} does) and clips the overflow, so the element needs a width to cut at: it is drawn as an inline block unless block is set, because a plain inline box never clips. Fluent's truncate.

italicbooleanNo

Draws the text in italics. Fluent's italic.

underlinebooleanNo

Draws a line under the text. With strikethrough both lines show. Fluent's underline.

strikethroughbooleanNo

Draws a line through the text. With underline both lines show. Fluent's strikethrough.

align'start' | 'center' | 'end' | 'justify'No

Aligns the text inside its box: 'start' and 'end' follow the writing direction, 'center' and 'justify' do not. It has an effect on a block box, so pair it with block for a span. Fluent's align.

blockbooleanNofalse

Draws the element as a block box that takes the full width, instead of the inline box of a <span>. Fluent's block.

asReact.ElementTypeNo'span'

Render as a different element or component (its props are type-checked).

Any other prop is passed to the element it renders (HTMLSpanElement).

Stable class names

PartClass
rootwave-text