Skip to content

Picker

Use Picker to let a shopper select one option from a dropdown. It supports primary and secondary variants, two sizes, an optional icon, and a floating label.

The SDK Picker showing a floating Size label with Medium selected.
import { Picker } from '/@dropins/tools/components.js';
PropTypeReq?Description
optionsPickerOption[]NoThe selectable options. Each option has a value, an optional text label, and an optional disabled flag.
valuestring | nullNoThe currently selected value. Update it later with setProps to change the selection programmatically.
defaultOptionPickerOptionNoThe option selected by default.
namestringNoField name, used to map the value in a form.
placeholderstringNoText shown when no option is selected. Overridden by floatingLabel if both are set.
variant'primary' | 'secondary'NoVisual style. Defaults to primary.
size'medium' | 'large'NoPicker size. Defaults to medium.
floatingLabelstringNoFloating label text, shown as the placeholder option before a value is selected and above the field as a floating label afterward.
iconVNodeNoIcon rendered inside the picker.
disabledbooleanNoDisable the picker. Defaults to false.
disableWhenSinglebooleanNoAutomatically disable the picker and select its only option when just one is available. Defaults to true; set to false to keep the picker interactive with a single option.
errorbooleanNoShow the error state styling. Defaults to false.
idstringNoElement id. Defaults to the name value, or a generated id, when not set.
handleSelect(event: Event) => voidNoCalled when the shopper selects an option.

Picker also accepts standard HTML select attributes (for example, className), except value, size, and icon.

import { Picker, provider } from '/@dropins/tools/components.js';
await provider.render(Picker, {
name: 'sortBy',
variant: 'primary',
placeholder: 'Select an option',
options: [
{ value: 'option1', text: 'Option 1' },
{ value: 'option2', text: 'Option 2', disabled: true },
{ value: 'option3', text: 'Option 3' },
],
handleSelect: (event) => yourApplySort(event),
})(document.querySelector('.sort-by'));