Skip to main content

Checkbox

Use this component when you want to provide users with a clear selection option, such as for agreeing to terms and conditions or selecting multiple options from a list.

Anchor to accessibilityLabel
accessibilityLabel
string

A label that describes the purpose or contents of the element. When set, it will be announced to users using assistive technologies and will provide them with more context. When set, any children or label supplied will not be announced to screen readers.

Anchor to checked
checked
boolean

Whether the checkbox is active.

Anchor to disabled
disabled
boolean

Whether the checkbox can be changed.

Anchor to error
error
string

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 field. When no id is set, a globally unique value will be used instead.

Anchor to label
label
string

Visual content to use as the checkbox label.

string

An identifier for the checkbox that is unique within the nearest containing Form component.

Anchor to onChange
onChange
(value: boolean) => void

A callback that is run whenever the checkbox is changed. This callback is called with a boolean indicating whether the checkbox should now be active or inactive. This component is controlled, so you must store this value in state and reflect it back in the checked or value props.

Anchor to value
value
boolean

Whether the checkbox is active. This prop is an alias for checked, and can be useful in form libraries that provide a normalized API for dealing with both boolean and string values. If both value and checked are set, checked takes precedence.

Examples
import {render, Checkbox} from '@shopify/ui-extensions-react/admin';

render('Playground', () => <App />);

function App() {
return (
<Checkbox id="checkbox" name="checkbox">
Save this information for next time
</Checkbox>
);
}

Preview

Was this page helpful?