Products · Components

Button

A button the person taps to do something.

Use variant="primary" for the page's main action and secondary for the rest. outline and ghost are quieter still.

Children: Text, which can include Text, Link and Icon within a line

Example

The Button component
view.dml
<View gap="small">
  <Button onClick="pay" loading="{{ paying }}">Pay</Button>
  <Button variant="secondary">Add to cart</Button>
  <Button variant="outline">See details</Button>
  <Button variant="ghost">Not now</Button>
</View>
controller.ts
export default definePage({
  initialState: { paying: false },
  mutations: {
    pay: () => ({ paying: true }),
  },
});

Props

PropTypeWhat it is
variantprimary, secondary, outline, ghostsecondary is a quiet fill, outline only an outline, and ghost only its text. Default: primary.
tonestatus toneDraws the button in a tone's color, such as danger for one that deletes. Default: default.
sizesizeDefault: medium.
disabledbooleanDims it, and the person can't use it.
loadingbooleanShows a spinner and ignores taps, such as while a payment is sent.

Events

EventSendsNotes
onClickNothing

Keep reading

On this page