Skip to main content
Kaleidoscope

Text

A typographic component for sentences, paragraphs, and general basic pieces of text.

Hierarchy

The basic hierarchy of text sizes available. If no size is provided, it defaults to "m".

Editable example

Best practices

  1. Avoid manually applying a className to override the color, text-align, font-weight, or font-size. All of these parameters are handled by the component's props.
  2. Text components do not contain any inherent spacing. It's recommended to use the layout to determine spacing. Rather than applying a className and applying a margin or padding to the text, use the containing element with display: flex; or display: grid; and gap to determine spacing.

Element

Determines the underlying HTML element rendered by the component. By default it's a <span>, but can be changed to any other element such as a <p> for paragraph text.

Editable example

Secondary

Secondary text should be used to reduce emphasis on text with a fainter text color.

Editable example

Strong

Use the strong prop to make text appear bolder for emphasis. Note that this does not change the rendered HTML element to a <strong> tag. If the text is not just cosmetically bolder but should be read by a screen reader with more emphasis, you can also set it to render a <strong> tag with element="strong".

Editable example

Alignment

Alignment can be set using the align prop. Defaults to left aligned.

Editable example

Theme

Change the theme for text to match its context.

Editable example

Accessibility

Avoid manually overriding the text color and instead use the secondary prop to dim less important text and the theme prop to use appropriate colors for a light or dark theme. The default colors assigned for each of these props have been chosen to meet the WCAG AA minimum contrast ratio.

Figma text styles

There's an explicit mapping of text styles to React components for the standard and strong variants. Figma doesn't store text color or alignment in text styles though, so those variants need to be inferred. Rule of thumb is if the text color is Slate-80 in Figma, it should be the secondary variant.

Figma text styleReact component
Text/Size XL<Text size="xl">
Text/Size L<Text size="l">
Text/Size M<Text size="m">
Text/Size S<Text size="s">
Text/Size XS<Text size="xs">
Text/Strong/Size XL<Text strong size="xl">
Text/Strong/Size L<Text strong size="l">
Text/Strong/Size M<Text strong size="m">
Text/Strong/Size S<Text strong size="s">
Text/Strong/Size XS<Text strong size="xs">