Checkbox
Give users a clear way to make selections, such as agreeing to terms or choosing multiple items from a list.
Anchor to propertiesProperties
- 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 checkedcheckedboolean
Whether the control is active.
- Anchor to defaultCheckeddefaultCheckedboolean
Whether the control is active by default.
- Anchor to defaultIndeterminatedefaultIndeterminateboolean
- 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.
- 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.
- string
A unique identifier for the element.
- Anchor to indeterminateindeterminateboolean
- Anchor to labellabelstring
Visual content to use as the control label.
- Anchor to namenamestring
An identifier for the field that is unique within the nearest containing form.
- Anchor to requiredrequiredboolean
Whether the field needs a value. This requirement adds semantic value to the field, but it will not cause an error to appear automatically. If you want to present an error when this field is empty, you can do so with the
error
property.- Anchor to valuevaluestring
The value used in form data when the checkbox is checked.
Checkbox
- __@internals$4@5319
ElementInternals
- 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
- checked
Whether the control is active.
boolean
- 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
- defaultChecked
Whether the control is active by default.
boolean
- defaultIndeterminate
boolean
- 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.
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
- id
A unique identifier for the element.
string
- indeterminate
boolean
- label
Visual content to use as the control label.
string
- 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
- required
Whether the field needs a value. This requirement adds semantic value to the field, but it will not cause an error to appear automatically. If you want to present an error when this field is empty, you can do so with the `error` property.
boolean
- setAttribute
(name: string, value: string) => void
- value
The value used in form data when the checkbox is checked.
string
declare class Checkbox extends PreactCheckboxElement implements CheckboxProps {
get indeterminate(): CheckboxProps['indeterminate'];
set indeterminate(indeterminate: CheckboxProps['indeterminate']);
accessor defaultIndeterminate: CheckboxProps['defaultIndeterminate'];
constructor();
}
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<'input'>
- Anchor to inputinputCallbackEventListener<'input'>
CheckboxEvents
- change
CallbackEventListener<'input'>
- input
CallbackEventListener<'input'>
export interface CheckboxEvents {
change: CallbackEventListener<'input'>;
input: CallbackEventListener<'input'>;
}
CallbackEventListener
(EventListener & {
(event: CallbackEvent<T>): void;
}) | null
CallbackEvent
Event & {
currentTarget: HTMLElementTagNameMap[T];
}
Code
examples
Code
<s-checkbox label="Require a confirmation step" details="Ensure all criteria are met before proceeding" ></s-checkbox>
<!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-checkbox label="Require a confirmation step" details="Ensure all criteria are met before proceeding" ></s-checkbox> </body></html>