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 propertiesProperties
- Anchor to accessibilityLabelaccessibilityLabelstring
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 commandcommand'--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 commandForcommandForstring
Sets the element the commandFor should act on when this clickable is activated.
- Anchor to disableddisabledboolean
Disables the button, meaning it cannot be clicked or receive focus.
- Anchor to downloaddownloadstring
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.
- Anchor to hrefhrefstring
The URL to link to.
- If set, it will navigate to the location specified by
href
after executing theclick
event. - If a
is set, the
command
will be executed instead of the navigation.
- If set, it will navigate to the location specified by
- Anchor to iconicon"" | "replace" | "search" | "link" | "product" | "variant" | "collection" | "select" | "info" | "incomplete" | "complete" | "color" | "money" | "adjust" | "affiliate" | "airplane" | "alert-bubble" | "alert-circle" | "alert-diamond" | "alert-location" | "alert-octagon-filled" | "alert-octagon" | "alert-triangle-filled" | "alert-triangle" | "app-extension"
The type of icon to be displayed in the button.
- Anchor to interestForinterestForstring
Sets the element the interestFor should act on when this clickable is activated.
- Anchor to loadingloadingboolean
Replaces content with a loading indicator while a background action is being performed.
This also disables the button.
- Anchor to targettarget"auto" | AnyString | "_blank" | "_self" | "_parent" | "_top"
Specifies where to display the linked URL.
- Anchor to tonetone"critical" | "auto" | "neutral"
Sets the tone of the Button, based on the intention of the information being conveyed.
- Anchor to typetype"button" | "reset" | "submit"
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/
command
and one of them is set.- Anchor to variantvariant"auto" | "primary" | "secondary" | "tertiary"
Changes the visual appearance of the Button.
AnyString
Prevents widening string literal types in a union to `string`.
string & {}
Anchor to eventsEvents
Learn more about registering events.
- Anchor to blurblurCallbackEventListener<typeof tagName> | null
- Anchor to clickclickCallbackEventListener<typeof tagName> | null
- Anchor to focusfocusCallbackEventListener<typeof tagName> | null
CallbackEventListener
(EventListener & {
(event: CallbackEvent<T>): void;
}) | null
CallbackEvent
Event & {
currentTarget: HTMLElementTagNameMap[T];
}
Code
Examples
Code
Default
<s-button variant="primary">Add Product</s-button> <s-button variant="secondary">Save Theme</s-button>