Text
Text is a basic typography component for outputting any supported text style provided by our design tokens.
Import#
import { Text } from '@volue/wave-react';
Examples#
Basic#
Use Text as a wrapper component that will apply constrained set of styles to the text inside. Available text styles are derived from our typography tokens.
Text should be used for any non-heading text. If you need to define a semantically relevant title to a component, section or page, use Heading component.
Custom semantics#
Text component will render an HTML span element by default, but via the as property, you can set it to render as any HTML element to ensure the underlying document semantics are meaningful. For example, using a p element for marking-up a paragraph.
Visual variants#
Text comes with two built-in variants used for displaying long-form writing. These variants are represented by font-size, font-weight, line-height and font-family values.
-
epsilonis the default variant used for most body text. -
zetavariant is recommended for small components and conserving space in data-heavy layouts. -
etavariant is suitable for small amounts of additional information in data-heavy layouts. Use in moderation.
To change the visual variant, use the variant property.
Custom styling#
Apart from selecting variant, you can freely manipulate Text styling, by passing style properties for common text styles. These properties include fontFamily, fontSize, fontWeight, letterSpacing, colorandlineHeight.
You can only select design tokens as the value of each property. Combination of the different properties is possible.
Responsive#
Any style or variant property supported by the Text component is responsive, meaning it can accept either a single value or an object that maps values to breakpoints defined in Wave.
For example, you may provide responsive values describing font stack, sizes and weights of each breakpoint:
Alignment#
Text can be aligned via the align prop.
Overflow strategy#
Use the overflowStrategy property to manage how Text behaves with regard to overflow. For example, if you’re displaying user-generated content that may not fit within your layout, you can truncate text with the overflowStrategy set to truncate.
Tabular numbers#
Enable useTabularNumbers property to make numeric glyphs have uniform/tabular widths (rather than proportional).
This enables columns of numbers to line up properly, which makes scanning numerical data easier and less error-prone (especially useful in large tables).
API Reference#
In addition to the props below, you can pass Box props to control the spacing.
Prop | Type | Default |
|---|---|---|
as | enum | span |
css | StitchesCss | No default value |
variant | enum | No default value |
fontFamily | enum | No default value |
fontSize | enum | No default value |
fontWeight | enum | No default value |
lineHeight | enum | No default value |
letterSpacing | enum | No default value |
color | ColorToken | No default value |
align | enum | No default value |
useTabularNumbers | boolean | No default value |
overflowStrategy | enum | No default value |