The Text component is used to display content on your page.
import { Text } from '@backstage/ui';
<Text>This is a text component</Text>| Prop | Type | Default | Responsive |
|---|---|---|---|
| variant | title-largetitle-mediumtitle-smalltitle-x-smallbody-largebody-mediumbody-smallbody-x-small | body-medium | Yes |
| weight | regularbold | regular | Yes |
| color | primarysecondarytertiarydangerwarningsuccess | primary | Yes |
| as | pspandivlabellegend | span | No |
| 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="2">
<Text variant="title-large">Title Large</Text>
<Text variant="title-medium">Title Medium</Text>
<Text variant="title-small">Title Small</Text>
<Text variant="title-x-small">Title X-Small</Text>
<Text variant="body-large">Body Large</Text>
<Text variant="body-medium">Body Medium</Text>
<Text variant="body-small">Body Small</Text>
<Text variant="body-x-small">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="2">
<Text weight="regular">Regular weight</Text>
<Text weight="bold">Bold weight</Text>
</Flex>The Text component has a color prop that can be used to change the
appearance of the text.
<Flex direction="column" gap="2">
<Text color="primary">Primary color</Text>
<Text color="secondary">Secondary color</Text>
<Text color="tertiary">Tertiary color</Text>
<Text color="danger">Danger color</Text>
<Text color="warning">Warning color</Text>
<Text color="success">Success color</Text>
</Flex>The Text component has a truncate prop that can be used to truncate the text.
<div style={{ width: '200px' }}>
<Text truncate>
This is a very long text that will be truncated when it exceeds the
container width
</Text>
</div>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