Text
The fundamental text primitive.
Text has built in accessibility controls, enforces inline layout by default, provides limited inheritance of text styles, and supports View as children. It inherits typographic styles from ancestor Text
elements (as long as the chain of text elements is not interrupted by a View
). By default, text is rendered using the native platform’s algorithm to determine the directionality of the content language. Accessibility props map directly to WAI-ARIA properties (excluding properties and values that are deprecated, redundant, or to be avoided).
import { Text } from 'react-gui/text';
<Text {...props} />
API #
Props #
The children of a Text
element can be strings as well as other elements like <View />
and <Image />
.
Set whether the view can receive keyboard focus.
If href
is defined, the view is rendered as an anchor tag pointing to this URL.
If href
is defined, this prop defines related attributes to include on the anchor (e.g., download
, rel
, target
) which may modify its behavior.
Set the styles of the view.
Set the test selector label (via data-testid
).
Style #
Did you know? Styling text in React GUI uses stricter rules than you might be used to working on the web. Read the Styling guide to learn more.
Details #
By default, the native writing direction is set to "auto"
and uses the browser’s built-in writing direction algorithm.
Nested text. Nested view/image.
How text styling inheritance works.
Render down to strings if no props or refs.