Skip to main content
For development, import Text from @servicetitan/anvil2. For design, find it in the Anvil2 file.

Options

Text supports body text, headline, and eyebrow configurations with multiple sizing options to accommodate various typography scenarios.

Body Text

Body Text sizing

Styling

Headline

Headline sizing

Eyebrow

Eyebrow sizing

Behavior

Text responds to different style and size requirements while maintaining consistent typography.

Usage Guidelines

Content

Content within Text should follow typography best practices for readability and hierarchy.

Accessibility

Out of the box, text provides necessary accessibility around sizing and color contrast.

Text color contrast with backgrounds

Text should follow the WCAG AA guidance on color contrast. By default, Anvil’s Text will provide at least 4.5:1 contrast with a white background. Use caution when using subdued on other background values, or when using custom color values in general, as they may not meet contrast guidance. For more guidance on text hierarchy and semantic markup, see semantic markup best practices.

Code

Common Examples

Text variants

The Text component accepts one of three options for the variant prop:
  • "body" (default): renders as HTML p or span element, if inline is set to true
  • "eyebrow": renders as HTML span element
  • "headline": renders as HTML heading element (h1 through h4) element, based on el prop

Body

Eyebrow

Headline

Headlines without a bottom margin

Headlines carry a bottom margin so they space correctly above the content that follows. When a headline is aligned against a sibling element instead, that trailing margin shifts it off center. Set noMargin to drop it:

Nesting body text

When using body text within body text, make sure to use the inline prop on any of the child Body components to render a span instead of p.

Subdued body text

If subdued is set to true on a body text, it will use a de-emphasized color:

The useAccessibleColor hook

The Anvil2 useAccessibleColor hook makes it easy to determine which text color to use given a specific background color without making it inaccessible. This hook accepts two parameters, and returns an object with both foreground and background colors. In the case that no color can be made accessible with the given color, the background color will be adjusted until it can.
Note: Anvil2 components and tokens already account for accessible colors internally, so this hook should only be needed when working with custom colors.
Last modified on October 27, 2026