Checkbox
A checkbox form input for multi-choice user selection
<Stack><Checkbox id="checkbox-option1" label="Option 1" /><Checkbox id="checkbox-option2" label="Option 2" /></Stack>
PropsLink to this heading
Link to this heading
<Checkbox>
import { Checkbox } from '@strum/react';
name | type | default |
---|---|---|
checked | CheckedState | - |
error | string | - |
id* Required | string | - |
label* Required | string | - |
onCheckedChange | (checked: CheckedState) => void | - |
ref | Ref<HTMLButtonElement> | - |
Disabled stateLink to this heading
Link to this heading
<Stack><Checkbox id="enabled-checkbox1" label="Option 1" /><Checkbox disabled id="disabled-checkbox2" label="Option 2" /><Checkbox id="enabled-checkbox3" label="Option 3" /></Stack>
Error stateLink to this heading
Link to this heading
<Stack><Checkboxerror="You must agree to the terms of service"id="error-checkbox1"label="I agree"/></Stack>
Controlled inputLink to this heading
Link to this heading
To control your checkbox component with React, simply include a checked boolean prop and a onCheckedChange function prop.
<Checkboxchecked={checked}id="controlled-checkbox"label={`The value is ${checked}`}onCheckedChange={changeCheckboxValue}/>