Use Button...
- To trigger an in-page action such as submitting a form or showing/hiding an interface component.
Don't use Button...
- Link to another page. Use Link instead, or render the Button as a lin
The preview has been updated.
Skin
Secondary
Use skin="secondary"
for all Buttons by default. Multiple secondary actions can be displayed on a page.
The preview has been updated.
Primary
Use skin="primary"
for the main action of the page.
- Limit to a single
primary
Button per page if possible to guide users through the purchasing flow and help them easily get to the cart. - Multiple primary buttons can be used for upsell (adding extra items to checkout).
The preview has been updated.
Tertiary
Use skin="tertiary"
when a more subtle Button is required.
The preview has been updated.
Destructive Primary
Use skin="destructive-primary"
if an action will destroy data, usually within a confirmation Modal Dialog. Refer to the Destructive Actions pattern for more information.
The preview has been updated.
Destructive Secondary
Use skin="destructive-secondary"
to indicate an action will destroy data. This action would usually trigger a Modal Dialog confirming the destruction of data. Refer to the Destructive Actions pattern for more information.
The preview has been updated.
Destructive Tertiary
Use skin="destructive-tertiary"
when a more subtle Button
is required. This action would usually trigger a Modal Dialog confirming the destruction of data. Refer to the Destructive Actions pattern for more information.
The preview has been updated.
Size
size
is deprecated in SWAN v3.3
The component now automatically handles sizing based on the selected mode(standardMode
/compactMode
). Please update your implementation to rely on the new mode-based sizing.
Use size="mini"
to reduce the size of a Button.
The preview has been updated.
Width
Use width="full-width"
to grow a Button to fill its container.
The preview has been updated.
Disabled
Disabled buttons can block user progress without explaining why. Where possible, keep buttons enabled and guide users on what to do instead.
Use disabled
when a Button’s action is unavailable.
Use the attribute aria-disabled="true"
if the HTML tag does not support the disabled
attribute. Notably this applies to span
.
The preview has been updated.
Icons
An Icon can be placed inside Buttons. Use buttonShape="round"
for icon only buttons.
Use objectFit
to accommodate different-sized custom icons.
buttonShape
is deprecated in SWAN v3.22.0
For icon only buttons use IconButton component
If the Button has no text you must include accessible text via aria-label
on Button
or with an alt
attribute on Icon
.
The preview has been updated.
Loading
Use loading
to indicate that an action is in progress. The Button will render a Spinner to visually indicate the loading state.
For assistive technologies, the visual updates must be accompanied by an ARIA live region on your page (not as a descendant of Button) to announce changes even when the Button is not in focus. Do not render this live region conditionally as it can lead to announcement issues. Instead render the text inside the live region conditionally. An example can be seen below:
The preview has been updated.
The preview has been updated.
Design Path
Use specialVariant="design-path"
for Buttons in the design path flow that require a second line for a description.
The preview has been updated.
Clear Selection
Use skin="clear-selection"
for Buttons that show user selections.
These Buttons require visually hidden text inside them which must be localized, to make it clear to assistive technologies what the action of clicking on the button will do.
The preview has been updated.
Button as a Link
Use render
for Buttons with the behavior of a Link. Refer to render prop guidelines.
Buttons that take users to a new page should render an <a>
instead of a <button>
for accessibility requirements.
The preview has been updated.
Use the attribute aria-disabled="true"
if the HTML tag does not support the disabled
attribute.
The preview has been updated.
Link as a Button
Use render
for Links with the behavior of a Button. Refer to render prop guidelines.
Buttons that take users to a new page should render an <a>
instead of a <button>
for accessibility requirements.
The preview has been updated.
Use disabled
when it's action is unavailable.
The preview has been updated.
Unstyled
Use skin="unstyled"
for Buttons with no styling.
This variant provides no affordance on touch devices and little affordance on desktops, so should only be used to wrap a component that provides its own affordance.
The preview has been updated.
Buttons in Banner
When used inside Banner, Buttons have a different styling to make them more neutral. This allows them to sit on a wide range of colors often used as Banner backgrounds without clashing.
The preview has been updated.