FormControl
FormControl provides Checkbox, Radio, and Toggle components for boolean and selection inputs.
Import
import { Checkbox, Radio, Toggle } from "@raydenui/ui";Checkbox
Basic
Preview
<Checkbox label="I agree to the terms" />With Description
Preview
<Checkbox label="Email notifications" description="Receive email updates about your account" />States
Preview
Controlled
const [checked, setChecked] = useState(false);
<Checkbox
label="Subscribe to newsletter"
checked={checked}
onChange={(e) => setChecked(e.target.checked)}
/>;Checkbox Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Checkbox label |
description | string | — | Additional description text |
checked | boolean | false | Controlled checked state |
onChange | ChangeEventHandler<HTMLInputElement> | — | Native change handler; read e.target.checked |
disabled | boolean | false | Disables the checkbox |
Radio
Basic Group
Preview
const [value, setValue] = useState("option1");
<div className="space-y-2">
<Radio
name="options"
value="option1"
label="Option 1"
checked={value === "option1"}
onChange={() => setValue("option1")}
/>
<Radio
name="options"
value="option2"
label="Option 2"
checked={value === "option2"}
onChange={() => setValue("option2")}
/>
<Radio
name="options"
value="option3"
label="Option 3"
checked={value === "option3"}
onChange={() => setValue("option3")}
/>
</div>;With Description
Preview
<Radio
name="plan"
value="pro"
label="Pro Plan"
description="$29/month, unlimited features"
checked={plan === "pro"}
onChange={() => setPlan("pro")}
/>Radio Props
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | — | Radio group name (required) |
value | string | — | Radio value (required) |
label | string | — | Radio label |
description | string | — | Additional description text |
checked | boolean | false | Controlled checked state |
onChange | ChangeEventHandler<HTMLInputElement> | — | Native change handler |
disabled | boolean | false | Disables the radio |
Toggle
Basic
Preview
<Toggle label="Dark mode" />With Description
Preview
<Toggle label="Auto-save" description="Automatically save changes every 5 minutes" />States
Preview
Controlled
const [enabled, setEnabled] = useState(false);
<Toggle
label="Notifications"
checked={enabled}
onChange={(e) => setEnabled(e.target.checked)}
/>;Toggle Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Toggle label |
description | string | — | Additional description text |
checked | boolean | false | Controlled checked state |
onChange | ChangeEventHandler<HTMLInputElement> | — | Native change handler; read e.target.checked |
disabled | boolean | false | Disables the toggle |
Accessibility
- All components use semantic HTML inputs
- Labels properly associated with inputs
- Focus visible styles for keyboard navigation
- ARIA attributes for screen readers
Last updated on