Skip to main content

Text

Used to apply Abyss typography styles to text elements

Submit feedback
github

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';
<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'.

Note: 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
'span'
-
The HTML element to use for the text
children
React.ReactNode
-
The text content to display
className
string
--
CSS class name to apply to each element within the component
color
Property.Color | undefined
'$web.semantic.color.text.content.secondary'
-
The color of the text
css
Abyss.CSSProperties | Partial<Record<`abyss-${T}`, Abyss.CSSProperties>>
--
Object containing CSS styling to apply; uses the classes listed in the "Integration" tab of the component's documentation

See CSS Prop Styling for more information
data-testid
string
--
Suffix used to create a unique ID used for automated testing

See Component Testing for more information
disableDefaultProviderProps
boolean
false
-
If set to true, the component will not use the DefaultPropsProvider values.

If you aren’t using the DefaultPropsProvider, this prop can be ignored.
fontSize
"lg" | "md" | "sm" | "xs"
'md'
-
The font size of the text
fontWeight
"bold" | "medium" | "regular"
'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