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.

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.

'--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.
string

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

boolean
Default: false

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

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" | "adjust" | "affiliate" | "airplane" | "alert-bubble" | "alert-circle" | "alert-diamond" | "alert-location" | "alert-octagon" | "alert-octagon-filled" | "alert-triangle"

The type of icon to be displayed in the Button.

string

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

boolean
Default: false

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

This also disables the Button.

"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.

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

Changes the visual appearance of the Button.

Was this section helpful?

Learn more about registering events.

<typeof tagName> | null
<typeof tagName> | null
<typeof tagName> | null
Was this section helpful?

HTMLElement

The content of the Button.

Was this section helpful?

Code

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

Component examples

Demonstrates a simple button with default styling, automatically determining its visual variant and using a clear, action-oriented label.

Showcases different button variants with varying visual emphasis, helping merchants understand action priorities through distinct styling.

Illustrates button tones that signal the semantic importance and potential impact of different actions through color and styling.

Showcases a button that combines a descriptive text label with an intuitive icon, enhancing visual communication of the action.

Demonstrates an icon-only button with an accessibility label, providing a compact interface that remains screen reader friendly.

Illustrates buttons in various loading states, providing visual feedback during asynchronous operations.

Demonstrates buttons in different interaction states, showing how to represent disabled controls and submit actions within forms.

Demonstrates a button group with carefully aligned actions, showing how to create a clear visual hierarchy for form submission and cancellation.

Illustrates a button pair for destructive actions, using a critical tone to emphasize the potentially irreversible nature of the operation.

Demonstrates a button group for executing operations on multiple selected items.

Showcases a set of compact, icon-only buttons with accessibility labels, perfect for creating dense interfaces.

Demonstrates advanced button capabilities using command, commandFor, and interestFor properties to enable dynamic component communication.

Was this section helpful?

Basic usage

<s-button>Save</s-button>