Skip to main content

Text

Used to apply Abyss typography styles to text elements.

github
View source code

Migration Information

For teams migrating from the V1 to V2 component, please refer to the migration guide for changes to the component.
Component Guide
import { Text } from '@uhg-abyss/web/ui/Text';
      () => {
      return (
      <Text
      color="$web.semantic.color.text.content.secondary"
      fontSize="md"
      fontWeight="regular"
      >
      Lorem ipsum dolor sit amet.
      </Text>
      );
      };

      Color

      Use the color prop to set the color of the text. This prop accepts any valid CSS color identifier (RGB, HSL, named color, etc.) as well as Abyss color tokens. The default value is '$web.semantic.color.text.content.secondary'.

      Color contrast

      Text colors must meet the minimum 4.5:1 contrast ratio for normal text and 3:1 for large text as per WCAG 2.1 guidelines.

      Font size

      Use the fontSize prop to change the size of the text. The available options are 'lg', 'md', 'sm', and 'xs'. The default value is 'md'.

      Font weight

      Use the fontWeight prop to change the weight of the text. The available options are 'bold', 'medium', and 'regular'. The default value is 'regular'.

      Polymorphic component

      The Text component is polymorphic, meaning that the underlying HTML element can be changed using the asElement prop. By default, the component renders as a <span>.

      Text Props

      NameTypeDefaultRequiredDescription
      asElement
      string | undefined
      'span'
      -
      The HTML element to use for the text
      children
      React.ReactNode
      -
      The text content to display
      color
      React.CSSProperties['color'] | undefined
      '$web.semantic.color.text.content.secondary'
      -
      The color of the text
      fontSize
      'lg' | 'md' | 'sm' | 'xs' | undefined
      'md'
      -
      The font size of the text
      fontWeight
      'bold' | 'medium' | 'regular' | undefined
      'regular'
      -
      The font weight of the text

      Below are the link(s) to the relevant GitHub type files:

      Abyss.d.ts

      Text Classes

      Class NameDescription
      .abyss-text-rootThe text root
      Table of Contents