组件 · 数据展示
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 line of help in a custom layout. 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
| Situation | Use |
|---|---|
| Text in a layout of your own, with no component for it | Text |
| A title, a label, a description inside a component | The component's own part: PanelTitle, FieldLabel, DescriptionTerm |
| Text someone wrote in Markdown | Markdown |
| A name from code inside a sentence | InlineCode |
| An ID, a time or a count inside a sentence | Text.Mono with render={<span />}, without a fill (Typography) |
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 the larger sizes, foreground-muted for small, caption and meta, foreground-hint for group.
Variants
| Variant | Use for |
|---|---|
variant="muted" | Secondary text: previews, descriptions, labels (foreground-muted) |
variant="placeholder" | Tertiary text: times, IDs, group headings, a missing value (foreground-hint) |
variant="information", "success", "warning", "danger", "primary", "accent" | Text that carries its color's meaning (Meanings of color) |
size="tabular" | Numbers in a column, with figures of equal width |
Content
- Follow the casing in Typography: sentence case for text, Title Case only for what people click.
- 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 use
variant="danger"for error text. Error text isdanger-strong, from the field's error state (Field).
API
TextHeading
| Prop | 类型 | 默认值 |
|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 1 | |
| "primary" | "accent" | "warning" | "danger" | "default" | "information" | "muted" | "success" | "placeholder" | ||
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.
TextMono
| Prop | 类型 | 默认值 |
|---|---|---|
| "code" | "meta" | "tabular" | "code" | |
| "primary" | "accent" | "warning" | "danger" | "default" | "information" | "muted" | "success" | "placeholder" | ||
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.
TextSans
| Prop | 类型 | 默认值 |
|---|---|---|
| "body" | "caption" | "small" | "group" | "large" | "body" | |
| "primary" | "accent" | "warning" | "danger" | "default" | "information" | "muted" | "success" | "placeholder" | ||
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.