Choice List
Present multiple options to users, allowing either single selections with radio buttons or multiple selections with checkboxes.
Anchor to propertiesProperties
- Anchor to detailsdetailsstring
Additional text to provide context or guidance for the field. This text is displayed along with the field and its label to offer more information or instructions to the user.
This will also be exposed to screen reader users.
- Anchor to disableddisabledboolean
Disables the field, disallowing any interaction.
disabled
on any child choices is ignored when this is true.- Anchor to errorerrorstring
Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.
- Anchor to labellabelstring
Content to use as the field label.
- Anchor to labelAccessibilityVisibilitylabelAccessibilityVisibility"visible" | "exclusive"
Changes the visibility of the component's label.
visible
: the label is visible to all users.exclusive
: the label is visually hidden but remains in the accessibility tree.
- Anchor to multiplemultipleboolean
Whether multiple choices can be selected.
- Anchor to namenamestring
An identifier for the field that is unique within the nearest containing form.
- Anchor to valuesvaluesstring[]
An array of the
value
s of the selected options.This is a convenience prop for setting the
selected
prop on child options.
ChoiceList
- __@internals$3@5370
ElementInternals
- adoptedCallback
() => void
- attributeChangedCallback
(name: string) => void
- click
Like the standard `element.click()`, but you can influence the behavior with a `sourceEvent`. For example, if the `sourceEvent` was a middle click, or has particular keys held down, components will attempt to produce the desired behavior on links, such as opening the page in the background tab.
({ sourceEvent }?: ClickOptions) => void
- connectedCallback
() => void
- details
Additional text to provide context or guidance for the field. This text is displayed along with the field and its label to offer more information or instructions to the user. This will also be exposed to screen reader users.
string
- disabled
Disables the field, disallowing any interaction. `disabled` on any child choices is ignored when this is true.
boolean
- disconnectedCallback
() => void
- error
Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.
string
- formResetCallback
() => void
- label
Content to use as the field label.
string
- labelAccessibilityVisibility
Changes the visibility of the component's label. - `visible`: the label is visible to all users. - `exclusive`: the label is visually hidden but remains in the accessibility tree.
"visible" | "exclusive"
- multiple
Whether multiple choices can be selected.
boolean
- name
An identifier for the field that is unique within the nearest containing form.
string
- queueRender
Queue a run of the render function. You shouldn't need to call this manually - it should be handled by changes to @property values.
() => void
- setAttribute
(name: string, value: string) => void
- values
An array of the `value`s of the selected options. This is a convenience prop for setting the `selected` prop on child options.
string[]
declare class ChoiceList extends BaseClass$3 implements ChoiceListProps {
accessor disabled: ChoiceListProps['disabled'];
accessor name: ChoiceListProps['name'];
accessor error: ChoiceListProps['error'];
accessor details: ChoiceListProps['details'];
accessor multiple: ChoiceListProps['multiple'];
accessor label: ChoiceListProps['label'];
accessor labelAccessibilityVisibility: ChoiceListProps['labelAccessibilityVisibility'];
get values(): ChoiceListProps['values'];
set values(values: ChoiceListProps['values']);
/** @private */
formResetCallback(): void;
constructor();
/** @private */
connectedCallback(): void;
/** @private */
disconnectedCallback(): void;
}
ClickOptions
- sourceEvent
The event you want to influence the synthetic click.
ActivationEventEsque
export interface ClickOptions {
/**
* The event you want to influence the synthetic click.
*/
sourceEvent?: ActivationEventEsque;
}
ActivationEventEsque
- button
number
- ctrlKey
boolean
- metaKey
boolean
- shiftKey
boolean
export interface ActivationEventEsque {
shiftKey: boolean;
metaKey: boolean;
ctrlKey: boolean;
button: number;
}
Anchor to eventsEvents
Learn more about registering events.
- Anchor to changechangeCallbackEventListener<typeof tagName> | null
- Anchor to inputinputCallbackEventListener<typeof tagName> | null
ChoiceListEvents
- change
CallbackEventListener<typeof tagName> | null
- input
CallbackEventListener<typeof tagName> | null
export interface ChoiceListEvents {
change: CallbackEventListener<typeof tagName> | null = null;
input: CallbackEventListener<typeof tagName> | null = null;
}
CallbackEventListener
(EventListener & {
(event: CallbackEvent<T>): void;
}) | null
CallbackEvent
Event & {
currentTarget: HTMLElementTagNameMap[T];
}
Anchor to choiceChoice
Create options that let users select one or multiple items from a list of choices.
- Anchor to accessibilityLabelaccessibilityLabelstring
A label used for users using assistive technologies like screen readers. When set, any children or
label
supplied will not be announced. This can also be used to display a control without a visual label, while still providing context to users using screen readers.- Anchor to defaultSelecteddefaultSelectedboolean
Whether the control is active by default.
- Anchor to disableddisabledboolean
Disables the control, disallowing any interaction.
- Anchor to selectedselectedboolean
Whether the control is active.
- Anchor to valuevaluestring
The value used in form data when the control is checked.
Choice
- accessibilityLabel
A label used for users using assistive technologies like screen readers. When set, any children or `label` supplied will not be announced. This can also be used to display a control without a visual label, while still providing context to users using screen readers.
string
- adoptedCallback
() => void
- attributeChangedCallback
(name: string) => void
- click
Like the standard `element.click()`, but you can influence the behavior with a `sourceEvent`. For example, if the `sourceEvent` was a middle click, or has particular keys held down, components will attempt to produce the desired behavior on links, such as opening the page in the background tab.
({ sourceEvent }?: ClickOptions) => void
- connectedCallback
() => void
- defaultSelected
Whether the control is active by default.
boolean
- disabled
Disables the control, disallowing any interaction.
boolean
- disconnectedCallback
() => void
- queueRender
Queue a run of the render function. You shouldn't need to call this manually - it should be handled by changes to @property values.
() => void
- selected
Whether the control is active.
boolean
- setAttribute
(name: string, value: string) => void
- value
The value used in form data when the control is checked.
string
declare class Choice extends PreactCustomElement implements ChoiceProps {
accessor disabled: ChoiceProps['disabled'];
get selected(): boolean;
set selected(selected: ChoiceProps['selected']);
accessor value: ChoiceProps['value'];
accessor accessibilityLabel: ChoiceProps['accessibilityLabel'];
accessor defaultSelected: ChoiceProps['defaultSelected'];
constructor();
/** @private */
connectedCallback(): void;
/** @private */
disconnectedCallback(): void;
}
ClickOptions
- sourceEvent
The event you want to influence the synthetic click.
ActivationEventEsque
export interface ClickOptions {
/**
* The event you want to influence the synthetic click.
*/
sourceEvent?: ActivationEventEsque;
}
ActivationEventEsque
- button
number
- ctrlKey
boolean
- metaKey
boolean
- shiftKey
boolean
export interface ActivationEventEsque {
shiftKey: boolean;
metaKey: boolean;
ctrlKey: boolean;
button: number;
}
Anchor to slotsSlots
- Anchor to detailsdetailsHTMLElement
ChoiceSlots
- details
HTMLElement
export interface ChoiceSlots {
details?: HTMLElement;
}
Code
examples
Code
<s-choice-list label="Company name" name="Company name" details="The company name will be displayed on the checkout page." > <s-choice value="hidden">Hidden</s-choice> <s-choice value="optional">Optional</s-choice> <s-choice value="required">Required</s-choice> </s-choice-list>
<!DOCTYPE html><html><head><style>html, body {height:100%} body {box-sizing: border-box; margin: 0; padding:0.5rem; display: grid; place-items: center; gap: 0.5rem;}</style><script src="https://cdn.shopify.com/shopifycloud/app-bridge-ui-experimental.js"></script></head><body><s-choice-list label="Company name" name="Company name" details="The company name will be displayed on the checkout page." > <s-choice value="hidden">Hidden</s-choice> <s-choice value="optional">Optional</s-choice> <s-choice value="required">Required</s-choice> </s-choice-list> </body></html>