A bare checkbox control (built on Radix's `Checkbox`) — the Radix checkbox button is this component's own root element. It has no built-in label/hint/error; wrap it in `FormField` for that chrome.
Examples of v0.5.2 are shown as code; only the latest version runs live. Open the live examples →
Basic Checkbox
1const BasicCheckbox = () => {2 const [checked, setChecked] = useState(false);3 return (4 <Checkbox5 checked={checked}6 onCheckedChange={(val) => setChecked(val === true)}7 />8 );9};1011render(<BasicCheckbox />);
Checkbox With Form Field
1const CheckboxWithFormField = () => {2 const [checked, setChecked] = useState(false);3 return (4 <FormField5 label="Accept terms and conditions"6 htmlFor="accept-terms"7 hint="You can withdraw consent at any time."8 >9 <Checkbox10 id="accept-terms"11 checked={checked}12 onCheckedChange={(val) => setChecked(val === true)}13 />14 </FormField>15 );16};1718render(<CheckboxWithFormField />);
Checkbox With Error
1const CheckboxWithError = () => (2 <FormField3 label="Agree to terms"4 htmlFor="agree"5 error="You must agree to continue"6 >7 <Checkbox id="agree" invalid checked={false} onCheckedChange={() => {}} />8 </FormField>9);1011render(<CheckboxWithError />);
Indeterminate Checkbox
1const IndeterminateCheckbox = () => (2 <Checkbox checked="indeterminate" onCheckedChange={() => {}} />3);45render(<IndeterminateCheckbox />);
Disabled Checkbox
1const DisabledCheckbox = () => (2 <Checkbox disabled checked={false} onCheckedChange={() => {}} />3);45render(<DisabledCheckbox />);
Required Checkbox
1const RequiredCheckbox = () => {2 const [checked, setChecked] = useState(false);3 return (4 <FormField5 label="I have read the privacy policy"6 htmlFor="privacy"7 required8 >9 <Checkbox10 id="privacy"11 required12 checked={checked}13 onCheckedChange={(val) => setChecked(val === true)}14 />15 </FormField>16 );17};1819render(<RequiredCheckbox />);