The Text component is used to display content on your page.
import { Text } from '@backstage/ui';
<Text />| Prop | Type | Default | Responsive |
|---|---|---|---|
| as | h1h2h3h4h5h6pspanlabeldivstrongemsmall | span | Yes |
| variant | title-largetitle-mediumtitle-smalltitle-x-smallbody-largebody-mediumbody-smallbody-x-small | - | Yes |
| weight | regularbold | - | Yes |
| color | primarysecondarydangerwarningsuccess | primary | Yes |
| truncate | boolean | false | No |
| children | ReactNode | - | No |
| className | string | - | No |
| style | CSSProperties | - | No |
The Text component has a variant prop that can be used to change the
appearance of the text.
<Flex direction="column" gap="4">
<Text variant="title-large">...</Text>
<Text variant="title-medium">...</Text>
<Text variant="title-small">...</Text>
<Text variant="title-x-small">...</Text>
<Text variant="body-large">...</Text>
<Text variant="body-medium">...</Text>
<Text variant="body-small">...</Text>
<Text variant="body-x-small">...</Text>
</Flex>The Text component has a weight prop that can be used to change the
appearance of the text.
<Flex direction="column" gap="4">
<Flex>
<Text variant="title-large" weight="regular">A fox</Text>
<Text variant="title-large" weight="bold">A turtle</Text>
</Flex>
<Flex>
<Text variant="title-medium" weight="regular">A fox</Text>
<Text variant="title-medium" weight="bold">A turtle</Text>
</Flex>
<Flex>
<Text variant="title-small" weight="regular">A fox</Text>
<Text variant="title-small" weight="bold">A turtle</Text>
</Flex>
<Flex>
<Text variant="title-x-small" weight="regular">A fox</Text>
<Text variant="title-x-small" weight="bold">A turtle</Text>
</Flex>
<Flex>
<Text variant="body-large" weight="regular">A fox</Text>
<Text variant="body-large" weight="bold">A turtle</Text>
</Flex>
<Flex>
<Text variant="body-medium" weight="regular">A fox</Text>
<Text variant="body-medium" weight="bold">A turtle</Text>
</Flex>
<Flex>
<Text variant="body-small" weight="regular">A fox</Text>
<Text variant="body-small" weight="bold">A turtle</Text>
</Flex>
<Flex>
<Text variant="body-x-small" weight="regular">A fox</Text>
<Text variant="body-x-small" weight="bold">A turtle</Text>
</Flex>
</Flex>The Text component has a color prop that can be used to change the
appearance of the text.
<Flex direction="column" gap="4">
<Text color="primary">I am primary</Text>
<Text color="secondary">I am secondary</Text>
<Text color="danger">I am danger</Text>
<Text color="warning">I am warning</Text>
<Text color="success">I am success</Text>
</Flex>The Text component has a truncate prop that can be used to truncate the text.
A man looks at a painting in a museum and says, “Brothers and sisters I have none, but that man's father is my father's son.” Who is in the painting?
<Text as="p" truncate>...</Text>You can also use the variant prop to change the appearance of the text based
on the screen size.
<Text variant={{ initial: 'body', lg: 'subtitle' }}>
Responsive text
</Text>Our theming system is based on a mix between CSS classes, CSS variables and data attributes. If you want to customise this component, you can use one of these class names below.
bui-Textbui-Text[data-variant="subtitle"]bui-Text[data-variant="body"]bui-Text[data-variant="caption"]bui-Text[data-variant="label"]bui-Text[data-weight="regular"]bui-Text[data-weight="bold"]bui-Text[data-color="primary"]bui-Text[data-color="secondary"]bui-Text[data-color="danger"]bui-Text[data-color="warning"]bui-Text[data-color="success"]bui-Text[data-truncate="true"]bui-Text[data-truncate="false"]0.9.0 - Fixed Text component to prevent truncate prop from being spread to the underlying DOM element. #316150.8.2 - Fix default text color in Backstage UI #314290.8.2 - Fix the default font size in Backstage UI. #314350.8.2 - Fix default font wight and font family in Backstage UI. #314320.7.0 - Breaking We are upgrading our Text component to support all font sizes making the Heading component redundant. The new Text component introduces 4 sizes for title and 4 sizes for body text. All of these work in multiple colors and font weights. We improved the as prop to include all possible values. The Link component has also been updated to match the new Text component. #305920.7.0 - Breaking We are upgrading our Text component to support all font sizes making the Heading component redundant. The new Text component introduces 4 sizes for title and 4 sizes for body text. All of these work in multiple colors and font weights. We improved the as prop to include all possible values. The Link component has also been updated to match the new Text component. #305920.6.0 - Update return types for Heading & Text components for React 19. #304400.4.0 - Add truncate prop to Text and Heading #299880.4.0 - Improve the way we treat custom render on Text and Heading #299890.3.0 - Update textDecoration to none on Text / Heading #293570.3.0 - Update textDecoration to none on Text / Heading #293570.2.0 - Improve Text styles #29200