Text provides an ergonomic API for rendering text. It includes built-in support for Canvas type tokens.

yarn add @workday/canvas-kit-react
yarn add @workday/canvas-kit-react

Usage Guidance

Coming soon!


Basic Example

Text is built on top of Box and supports a multitude of style props including spacing props such as margin and padding, as well as text styling props such as fontSize and fontWeight.

Text renders a <span> element by default. You may override the rendered element using the as prop.

Text as h4

Text styled using style props

Text styled using type token level

Text with inherited styles

Type Level and Variant

Text includes built-in support for Canvas type tokens via the typeLevel and variant props.

typeLevel hooks into the Canvas type hierarchy.

Small Body level text

variant allows you to layer additional styling to aid users' understanding of the text being rendered.

Error text

Component API


This is a generic base component intended to render any text. It's built on top of the component. It also has typeLevel and variant style props that simplify navigating our type hierarchy and using Canvas type tokens. By default, it renders a semantic span element, but you can adjust this as needed with the as prop.

The type hierarchy is organized into four levels, which correspond to our Canvas type levels.

  • title: Intended to be used for large page titles.
  • heading: Intended to be used for headings and large text.
  • body: Intended to be used for standard body text.
  • subtext: Intended to be used for small subtext content or in tight spaces.

Each level has three sizes: large, medium, and small.

You can provide any level and size to the typeLevel prop, and it will apply the correct styles accordingly. In the example below we're providing the subtext level and small size to the component with the value subtext.small.

import { Text } from '@workday/canvas-kit-react/text';
const CustomErrorText = () => (
<Text typeLevel="subtext.small" variant="error">
Error Text

Layout Component

Text supports all props from thelayout component.


Props extend from span. Changing the as prop will change the element interface.


Type token as string with level and size separated by dot. These values map to our Canvas type levels.

<Text typeLevel="body.small">Small body text</Text>

Type variant token names: error, hint or inverse.

<Text variant="error" typeLevel="subtext.large">Error text</Text>

The cs prop takes in a single value or an array of values. You can pass the CSS class name returned by , or the result of and . If you're extending a component already using cs, you can merge that prop in as well. Any style that is passed to the cs prop will override style props. If you wish to have styles that are overridden by the css prop, or styles added via the styled API, use wherever elemProps is used. If your component needs to also handle style props, use instead.

import {handleCsProp} from '@workday/canvas-kit-styling';
import {mergeStyles} from '@workday/canvas-kit-react/layout';
// ...
// `handleCsProp` handles compat mode with Emotion's runtime APIs. `mergeStyles` has the same
// function signature, but adds support for style props.
return (
{...handleCsProp(elemProps, [
myModifiers({ size: 'medium' }),
myVars({ backgroundColor: 'red' })

Optional override of the default element used by the component. Any valid tag or Component. If you provided a Component, this component should forward the ref using React.forwardRefand spread extra props to a root element.

Note: Not all elements make sense and some elements may cause accessibility issues. Change this value with care.

refReact.Ref<R = span>

Optional ref. If the component represents an element, this ref will be a reference to the real DOM element of the component. If as is set to an element, it will be that element. If as is a component, the reference will be to that component (or element if the component uses React.forwardRef).

Can't Find What You Need?

Check out our FAQ section which may help you find the information you're looking for.

FAQ Section