Overview Button Copy button Field Input Number field Textarea Select Combobox Multiselect Date picker Date range picker Date-time picker Checkbox Radio group Position picker Switch Slider Dropzone Device controls Avatar Badge Card Collapsible Kbd Map Matrix Proportion bar Separator Stat Table Timeline Chat Playback Pagination Charts Chart theming Profile chart Time series chart Bar chart Isopleth chart TS diagram Box plot Rose chart Calendar chart Banner Toast Loader Progress Skeleton Empty state Error state Dropdown menu Tooltip Info tooltip Dialog Sheet Resizable Confirm dialog Breadcrumbs Command palette Mobile menu Navigation list Outline Scroll rail Sidebar Tabs
Button
Triggers an action. Pass href to render a link that looks like a button.
Playground
Hover, press and tab to see interaction states. Press it while disabled to see the shake.
Variant
Size
Theme
<Button variant="primary" iconLeft="plus">New mission</Button> Variants
Sizes
md is the default. xs is for dense table rows and inline toolbars.
Icon only
Set square and give it an aria-label. A menu of more actions opens from the vertical ellipsis.
Loading and success
Click them. An action runs through three states on the same button, which keeps the width of its widest one so nothing beside it moves.
Disabled until there's something to save.
- Pending names the action, as a verb with three dots: Saving..., Sending..., Revoking... Never Loading...: it says something is happening, not what. Labelled buttons warn in dev without a loadingText.
- Success says it's done, in the past tense: Saved, Sent, Revoked. It shows for 2 seconds, then the button is back to normal. No toast on top for the same news.
- Failure isn't a button state. The button goes back to normal and the page says what went wrong, in a banner or next to the field, where there's room to explain.
- A button that removes its own row (Revoke on a list item) skips success: the row leaving is the success.
- Pending disables the button, so nothing fires twice. Use the Action helper: it runs the work, moves the button through the states and ignores a second click.
<script lang="ts">
const save = new Action(() => api.saveProfile(form));
</script>
<Button
variant="primary"
{...save.button}
disabled={!dirty}
loadingText="Saving..."
successText="Saved"
onclick={() => save.run()}
>
Save changes
</Button> When to use which
The one action the page or dialog exists for. At most one per view; if you can't pick, neither is primary.
Everything else. The default, and the right choice most of the time.
Confirming a destructive action, usually inside a confirm dialog. Not the button that opens it.
The button that opens a destructive action, like Delete or Leave. Its confirm dialog then has the solid danger button.
Toolbars, icon buttons and actions repeated on every row, where a border adds noise.
An action inside running text.