Widgets
Text
Text components for a Widget's words: Text, Title, Caption, Label and Markdown
Text components show every readable line in a Widget, from headings and body copy to field labels and formatted Markdown. There are five: Text, Title, Caption, Label and Markdown.
Common Props
Text, Title, Caption and Label share these props.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | number | — | The text to show. |
color | color | primary (secondary for Caption and Label) | Text color. Accepts the same colors as layout components. |
textAlign | start | center | end | start | Horizontal alignment. |
truncate | boolean | false | Keeps the text on one line and ends it with an ellipsis. |
maxLines | number | — | Shows at most this many lines and hides the rest. |
decimalPlaces | number | — | When value is a number, rounds it to this many decimal places, such as 2 for 49.90. |
Text
Body text for descriptions, values and any other copy.
<Text value={description} size="sm" color="secondary" maxLines={3} />Props
In addition to the common props, Text accepts:
| Prop | Type | Default | Description |
|---|---|---|---|
size | xs | sm | md | lg | xl | md | Font size: 12, 14, 16, 18 or 20 px. |
weight | normal | medium | semibold | bold | normal | Font weight. |
width | number | string | — | Fixed width. |
italic | boolean | false | Italic text. |
lineThrough | boolean | false | Strikes the text through, for example an old price. |
tabularNums | boolean | false | Gives every digit the same width so numbers line up. |
minLines | number | — | The least number of lines the text takes up. |
streaming | boolean | false | Shows the text with a fade-in, as if it were being written. |
editable | object | — | Turns the text into an inline field the visitor can edit. See below. |
Editable text
Give editable an object and the text becomes a field the visitor can change in place. Its value is stored under editable.name, like any form input.
<Text value={nickname} editable={{ name: "nickname", placeholder: "Add a nickname", required: true }} />editable takes name, placeholder, required, pattern, autoFocus, autoSelect, allowAutofillExtensions, autoComplete and onChangeAction. Set minLines or maxLines to edit several lines.
Title
Headings for cards and sections.
<Title value="Order summary" size="lg" />Props
In addition to the common props, Title accepts:
| Prop | Type | Default | Description |
|---|---|---|---|
size | sm | md | lg | xl | 2xl | 3xl | 4xl | 5xl | md | Font size: 18, 20, 24, 32, 36, 48, 60 or 72 px. |
weight | normal | medium | semibold | bold | medium | Font weight. |
tabularNums | boolean | false | Gives every digit the same width. |
Caption
Small secondary text for notes, dates and supporting details.
<Caption value="Estimated delivery Thu, 4 Dec" />Props
In addition to the common props, Caption accepts:
| Prop | Type | Default | Description |
|---|---|---|---|
size | sm | md | lg | md | Font size: 11, 12 or 14 px. |
weight | normal | medium | semibold | bold | normal | Font weight. |
Label
A label for a form field. Put it above an Input, Select or other control and set fieldName to the control's name.
<Label value="Email address" fieldName="email" />
<Input name="email" inputType="email" placeholder="you@example.com" />Props
In addition to the common props, Label accepts:
| Prop | Type | Default | Description |
|---|---|---|---|
fieldName | string | — | The name of the field this label belongs to. |
size | xs | sm | md | lg | xl | md | Font size: 12, 14, 16, 18 or 20 px. |
weight | normal | medium | semibold | bold | medium | Font weight. |
Markdown
Formatted text written in Markdown, including headings, lists, links, tables and code. Links open in a new tab.
<Markdown value={returnPolicy} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | The Markdown to show. |
streaming | boolean | false | Shows the text with a fade-in, as if it were being written. |