Skip to main content

Button

Triggers actions or events, such as submitting forms, opening dialogs, or navigating to other pages. Use Button to let users perform specific tasks or initiate interactions throughout the interface. Buttons can also function as links, guiding users to internal or external destinations.

Anchor to accessibilityLabel
accessibilityLabel
string

A label that describes the purpose or contents of the Button. It will be read to users using assistive technologies such as screen readers.

Use this when using only an icon or the Button text is not enough context for users using assistive technologies.

Anchor to command
command
'--auto' | '--show' | '--hide' | '--toggle'
Default: '--auto'

Sets the action the command should take when this clickable is activated.

See the documentation of particular components for the actions they support.

  • --auto: a default action for the target component.
  • --show: shows the target component.
  • --hide: hides the target component.
  • --toggle: toggles the target component.
Anchor to commandFor
commandFor
string

Sets the element the commandFor should act on when this clickable is activated.

Anchor to disabled
disabled
boolean
Default: false

Disables the Button meaning it cannot be clicked or receive focus.

Anchor to download
download
string

Causes the browser to treat the linked URL as a download with the string being the file name. Download only works for same-origin URLs or the blob: and data: schemes.

string

The URL to link to.

  • If set, it will navigate to the location specified by href after executing the click event.
  • If a commandFor is set, the command will be executed instead of the navigation.
"" | "replace" | "search" | "split" | "link" | "edit" | "product" | "variant" | "collection" | "select" | "info" | "incomplete" | "complete" | "color" | "money" | "order" | "code" | "adjust" | "affiliate" | "airplane" | "alert-bubble" | "alert-circle" | "alert-diamond" | "alert-location" | "alert-octagon"

The type of icon to be displayed in the Button.

Anchor to inlineSize
inlineSize
"auto" | "fill" | "fit-content"
Default: 'auto'

The displayed inline width of the Button.

  • auto: the size of the button depends on the surface and context.
  • fill: the button will takes up 100% of the available inline size.
  • fit-content: the button will take up the minimum inline-size required to fit its content.
Anchor to interestFor
interestFor
string

Sets the element the interestFor should act on when this clickable is activated.

Anchor to loading
loading
boolean
Default: false

Replaces content with a loading indicator while a background action is being performed.

This also disables the Button.

Anchor to target
target
"auto" | | "_blank" | "_self" | "_parent" | "_top"
Default: 'auto'

Specifies where to display the linked URL.

"critical" | "auto" | "neutral"
Default: 'auto'

Sets the tone of the Button based on the intention of the information being conveyed.

"button" | "reset" | "submit"
Default: 'button'

The behavior of the Button.

  • submit: Used to indicate the component acts as a submit button, meaning it submits the closest form.
  • button: Used to indicate the component acts as a button, meaning it has no default action.
  • reset: Used to indicate the component acts as a reset button, meaning it resets the closest form (returning fields to their default values).

This property is ignored if the component supports href or commandFor/command and one of them is set.

Anchor to variant
variant
"auto" | "primary" | "secondary" | "tertiary"
Default: 'auto' - the variant is automatically determined by the Button's context

Changes the visual appearance of the Button.

Learn more about registering events.

<TTagName> | null
Anchor to click
click
<TTagName> | null
Anchor to focus
focus
<TTagName> | null

Anchor to children
children
HTMLElement

The content of the Button.

Examples
<>
<s-button variant="primary">Add Product</s-button>
<s-button variant="secondary">Save Theme</s-button>
</>

Preview

  • Taking primary actions like saving or creating resources
  • Taking secondary actions like canceling forms or filtering results
  • Triggering destructive operations like deletion or disconnection
  • Accessing supplementary actions via tertiary buttons

  • Be clearly and accurately labeled with strong, actionable verbs
  • Use established button tones appropriately (e.g., critical tone only for actions that are difficult to undo)
  • Prioritize the most important actions to avoid confusion
  • Be positioned in consistent locations in the interface
  • Use buttons for actions and links for navigation

  • Use simple, concise verbs (e.g., "Save", "Edit", "Add tags")
  • Write in sentence case
  • Avoid unnecessary words and articles (e.g., "a", "an", "the")
  • Don't use punctuation
  • For icon-only buttons, use accessibilityLabel to describe the action
Was this page helpful?