Skip to content

ToggleButton

Use ToggleButton to let shoppers select one option from a set of mutually exclusive choices, rendered as a selectable button rather than a plain radio input. It is built on RadioButton and supports an optional leading icon.

The SDK ToggleButton showing a selected toggle option.
import { ToggleButton } from '/@dropins/tools/components.js';
PropTypeReq?Description
labelstring | VNodeYesLabel of the toggle button.
namestringYesField name, used for mapping the value in a form.
valuestringYesField value.
selectedbooleanNoWhether the toggle button is selected. Defaults to true.
disabledbooleanNoWhether the toggle button is disabled. Defaults to false.
busybooleanNoWhether the toggle button is in a loading state. Defaults to false.
iconVNodeNoIcon to display before the label (SVG or img element).
ariaLabelstringNoAccessible label for the toggle button.
onChange(value: string) => voidNoFunction called when the toggle button is clicked.

ToggleButton also accepts standard HTML attributes (for example, onClick, className), except onChange, icon, and label.

import { ToggleButton, provider } from '/@dropins/tools/components.js';
await provider.render(ToggleButton, {
label: 'Gift wrap',
name: 'gift-wrap',
value: 'yes',
selected: false,
onChange: (value) => yourUpdateGiftWrap(value),
})(document.querySelector('.toggle-button'));
  • Radio Button — the control this button is built on.
  • Design tokens — the colors, spacing, and typography the button uses.