Widgets
Interactive
The component visitors click to act: Button
Button
A button that runs a function when clicked, or submits the form it sits in. Buttons are how visitors act on a Widget: track a parcel, confirm a choice, open a page or reply in the chat.
<Button label="Track package" iconStart="truck" onClickAction={{ functionName: "trackPackage" }} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | {text, color?, weight?} | — | Button text. |
onClickAction | action | — | Function to run on click. |
submit | boolean | false | Submits the Form the button is in. |
variant | solid | soft | outline | ghost | solid | Visual style. |
color | primary | secondary | success | danger | warning | caution | info | discovery, or any color | primary | Button color. |
size | 3xs | 2xs | xs | sm | md | lg | xl | 2xl | 3xl | lg | Button height, from 22 px (3xs) to 48 px (3xl). lg is 36 px. |
iconStart | icon | — | Icon before the label. See Icon field format. |
iconEnd | icon | — | Icon after the label. |
iconSize | xs | sm | md | lg | xl | 2xl | 3xl | follows size | Size of both icons. |
pill | boolean | true | Fully rounded ends. Set pill={false} for rounded corners. |
block | boolean | false | Stretches the button to the full width of its container. |
width | number | string | — | Fixed width. |
uniform | boolean | false | Makes the button square, for an icon-only button. |
disabled | boolean | false | Greys the button out and blocks clicks. |
lineThrough | boolean | false | Strikes the label through. |
ariaLabel | string | the label | Name read by screen readers. Set it on icon-only buttons. |
While its function runs, a button shows a spinner and can't be clicked again, unless loadingBehavior is "none" or "container".
Examples
Basic action button
A button that runs one function.
<Button label="Refresh status" onClickAction={{ functionName: "refreshStatus" }} />Form submit button
With submit, the button submits its form, which runs the form's function with every field value. Use it in a Form or in a Card with asForm.
<Form onSubmitAction={{ functionName: "subscribe" }} gap={3}>
<Label value="Email" fieldName="email" />
<Input name="email" inputType="email" required />
<Button label="Subscribe" submit color="success" />
</Form>Icon buttons
Add an icon before or after the label with iconStart and iconEnd. For a square icon-only button, leave out label, set uniform and give it an ariaLabel.
<Button
label="Download invoice"
iconStart="download"
variant="outline"
color="secondary"
onClickAction={{ functionName: "downloadInvoice" }}
/><Button
iconStart="x"
uniform
variant="ghost"
ariaLabel="Close"
onClickAction={{ functionName: "close" }}
/>Full-width button
Set block to make the button fill its container.
<Button label="Continue to checkout" block pill={false} onClickAction={{ functionName: "checkout" }} />Button with additional inputs
Send a value along with the click. This matters for buttons drawn from a list, where each must say which item was clicked.
{items.map((item) => (
<Button
key={item.sku}
label={`Return ${item.name}`}
variant="outline"
onClickAction={{
functionName: "startReturn",
additionalInputs: { sku: item.sku }
}}
/>
))}