| [ Web Proxy ] |
| Viewing: https://shopify.dev/docs/api/checkout-ui-extensions/latest/web-components/actions/press-button | [Back] [Original] |
The press button component lets buyers toggle between active and inactive states. Use press button for persistent on/off or selected/unselected choices.
Press buttons provide visual feedback for pressed and unpressed states. For binary controls that take effect immediately without a save action, use switch instead.
Press button supports only a binary toggle state (pressed or unpressed). Multi-state or tri-state toggles aren't supported.
defaultPressed so buyers start with a suggested choice.Configure the following properties on the press button component.
A label that describes the purpose or content of the button for users of assistive technologies such as screen readers. Use this when the visible content alone doesn't provide enough context.
Whether the button is pressed by default.
Whether the button is disabled, preventing it from being clicked or receiving focus.
A unique identifier for the element. Use this to reference the element in JavaScript, link labels to form controls, or target specific elements for styling or scripting.
The inline width of the button component.
'auto': The size depends on the surface and context.'fill': The button takes up 100% of the available inline size.'fit-content': The button takes up the minimum inline size required to fit its content.The language of the button's text content. Use this when the button text is in a different language than the rest of the page, so assistive technologies can invoke the correct pronunciation. See the reference of values (Subtag label).
Whether the button is in a loading state, which replaces the button content with a loading indicator while a background action is being performed. This also disables the button.
Whether the button is pressed.
The press button component provides event callbacks for handling user interactions. Learn more about handling events.
A callback fired when the button loses focus.
Learn more about the blur event.
A callback fired when the button is clicked.
Learn more about the click event.
A callback fired when the button receives focus.
Learn more about the focus event.
A typed event listener for custom element events. The listener receives a `CallbackEvent` with the correct `currentTarget` type for the associated custom element tag.
(EventListener & {
(event: CallbackEvent<TTagName, Event> & TData): void;
}) | nullAn event type that narrows the `currentTarget` to the specific HTML element associated with the custom element tag. This provides type-safe event handling in callback listeners.
TEvent & {
currentTarget: HTMLElementTagNameMap[TTagName];
}s-press-button element for gift wrapping.s-press-button with the pressed attribute for a pre-selected option that the buyer can toggle off.s-press-button with the disabled attribute for an unavailable shipping method.defaultPressed when an option is commonly chosen, so buyers start with the recommended selection.disabled attribute to keep it visible and set expectations.| Web Proxy Viewer | New URL | Original Page |