Components · Data Display
Text
Plain typography parts — Text.Heading, Text.Sans and Text.Mono — for text that no other component holds, in the system's two typefaces.
import { Text } from "@botiverse/raft-ui";Text sets a run of text that no other component holds: a name under an avatar, a size next to a file name, a helper line in a custom layout (as a HelperText, with variant="muted"). Text.Sans is Space Grotesk, for what people say; Text.Mono is Space Mono, for what machines write; Text.Heading is a heading. Which typeface is for what is in Typography.
When to use
Anatomy
Text.Heading(TextHeading): anh1toh6, fromlevel.Text.Sans(TextSans): a paragraph in Space Grotesk, sized bysize:large,body,small,captionorgroup, the heading of a group of rows or a section in a panel (text-footnoteat 700,foreground-hint, as in Typography).Text.Mono(TextMono): a paragraph in Space Mono, sized bysize:code,metaortabular.
Each part takes a variant for its color. Without one, the size sets it: foreground for every Sans size but group, and for Mono code and tabular; foreground-hint for Mono meta (a note: a time, an ID, a count) and for group. small and caption were foreground-muted before raft-ui's HelperText release, and meta too: a size never makes text grey now, since grey text is helper text.
Variants
-
A color tone is its family's
-strongink, the shade made for text:informationisinfo-strong,accentattention-strong,successsuccess-strong,warningwarning-stronganddangerdanger-strong. Each is at least 4.5:1 on the canvas, the sidebar, a card and a popover, in both modes and every theme (text.tones.test.tsx). They were the sticker colorssuccess,warninganddanger, which are fills for ink type: as text on white they were 1.64:1, 2.03:1 and 2.76:1.accentwasattention-700, 8.0:1 on white but 2.15:1 on the dark canvas. -
variant="primary"isbrand-strong, the brand's shade for text: 8.9:1 on white and 12.1:1 on the dark canvas. It usedbrand-700, which was 3.1:1 (APCA Lc 22) on the dark canvas, and which no theme reached, so it stayed yellow-brown in Boring Gray. Yellow text is the brand, not a signal (a signal is a yellow sticker: Themes), so it grays with Boring Gray. -
The props are a union on
variant: with"muted"the children are aHelperText, with any other tone any children. A tone chosen at runtime (variant={quiet ? "muted" : "default"}) fits neither, so split the two cases: a helper line and a line of data are different text. -
Text.Headinghas nomuted: a heading is never helper text.
Content
- Follow the casing in Typography: sentence case for all text, what people click included.
- Set IDs, times, counts and sizes in
Text.Mono, even next to Space Grotesk:#25,10:24,24 KB.
Accessibility
- The parts are plain elements built with Base UI
useRender. Userenderto choose the element the document needs, such as aspaninside a row, ordtandddin a list of terms, while keeping the style. levelsets both the size and the element. To keep the page's outline, set the element withrender:level={6}withrender={<h2 />}for a name under a profile avatar.
Rules
- Head a section with
Text.Sans size="group", in sentence case. Don't set a small label in Space Mono or in all caps: nothing in the product is in all caps (Typography). - Don't color words with a sticker color or a palette step (
text-warning,text-success,text-danger,text-attention-700): take a tone, or its-strongtoken in a layout of your own. The sticker colors are for fills, with ink type and icons on them (Color › Contrast). - Don't use
variant="danger"for a field's error. It has the samedanger-strongink, but an error belongs to its field's error state, which also marks the field invalid (Field).
API
TextHeading
Also takes the attributes of its element.
TextMono
Also takes the attributes of its element.
TextSans
Also takes the attributes of its element.