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-Text
bui-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.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