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
export const Default: Story = {};Variants
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
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
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
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
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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
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: | |
font | 'base' | 'monospace' | 'numeric' | No | 'base' | Font family: |
wrap | boolean | No | true | Whether the text wraps. |
truncate | boolean | No | Cuts a line that does not fit its box with an ellipsis. It keeps the text on one line (as | |
italic | boolean | No | Draws the text in italics. Fluent's | |
underline | boolean | No | Draws a line under the text. With | |
strikethrough | boolean | No | Draws a line through the text. With | |
align | 'start' | 'center' | 'end' | 'justify' | No | Aligns the text inside its box: | |
block | boolean | No | false | Draws the element as a block box that takes the full width, instead of the inline box of a |
as | React.ElementType | No | '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
| Part | Class |
|---|---|
root | wave-text |