import AttributeMinHeight from './attributes/_minHeight.md'; import AttributeMaxHeight from './attributes/_maxHeight.md'; import AttributeMinWidth from './attributes/_minWidth.md'; import AttributeMaxWidth from './attributes/_maxWidth.md'; import AttributeGrow from './attributes/_grow.md'; import AttributeAlignment from './attributes/_alignment.md'; import AttributeOnPress from './attributes/_onPress.md'; import AttributeWidth from './attributes/_width.mdx'; import AttributeHeight from './attributes/_height.mdx'; import AttributeColor from './attributes/_color.md';
The <text> element enables you add and format text in your UI.
By default, text blocks are limited to a single line. If you have a lot of text, it grows horizontally and the overflow gets clipped. There are two properties to make working with multi-line text easier: wrap and overflow. For text to wrap onto a new line, there needs to be a width defined.
An enum for defining the text style. Shorthand for setting size, weight, and color at the same time. Possible values:
metadatabody: The default if the attribute is not used.heading
An enum for setting the text size and line height. Overrides the style attribute if both are set. Possible values:
xsmall- Text size: 10px
- Line height: 16px
small- Text size: 12px
- Line height: 16px
medium: The default if the attribute is not used.- Text size: 14px
- Line height: 20px
large- Text size: 16px
- Line height: 20px
xlarge- Text size: 18px
- Line height: 24px
xxlarge- Text size: 24px
- Line height: 28px
An enum for setting the text weight. Possible values:
regular: The default if the attribute is not used.bold
Defaults to neutral-content.
An enum for adding an outline to text. The outline is either white or black, depending on which color provides the most contrast against the text color. Possible values:
none: The default if the attribute is not used.thin: 1pxthick: 2px
A boolean for determining if users can select the text. Possible values:
true: The default if the attribute is not used.false
A boolean for toggling text wrapping, enabling text to wrap onto multiple lines. Only wraps if the width is constrained. Possible values:
truefalse: The default if the attribute is not used.
An enum for determining how text overflow is handled. Possible values:
clip: The default if the attribute is not used.ellipsis
<text onPress={() => console.log('world')}>Hello</text>Wrap the text onto a new line once the available width has been filled. The number of lines is a function of the font size and the text string length.
<text wrap>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam consectetur rutrum tempor.
</text>Set the overflow attribute to “ellipsis” provides a visual cue to users that there is additional text.
<text overflow="ellipsis">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam consectetur rutrum tempor. Donec
lacinia nulla dolor, eget iaculis quam imperdiet quis. Duis nec velit dignissim, lobortis ligula
eu, mattis arcu.
</text>Define the height to limit the number of lines occupied by the text.
<text maxHeight="60px" wrap overflow="ellipsis">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam consectetur rutrum tempor. Donec
lacinia nulla dolor, eget iaculis quam imperdiet quis. Duis nec velit dignissim, lobortis ligula
eu, mattis arcu. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam consectetur
rutrum tempor. Donec lacinia nulla dolor, eget iaculis quam imperdiet quis. Duis nec velit
dignissim, lobortis ligula eu, mattis arcu.
</text>Avoid UI shift by setting a fixed height.
<text height="60px">Hello world</text>




