Skip to Content
ComponentsFormControl

FormControl

FormControl provides Checkbox, Radio, and Toggle components for boolean and selection inputs.

Import

import { Checkbox, Radio, Toggle } from "@raydenui/ui";

Checkbox

Basic

<Checkbox label="I agree to the terms" />

With Description

<Checkbox label="Email notifications" description="Receive email updates about your account" />

States

Controlled

const [checked, setChecked] = useState(false); <Checkbox label="Subscribe to newsletter" checked={checked} onChange={setChecked} />;

Checkbox Props

PropTypeDefaultDescription
labelstring—Checkbox label
descriptionstring—Additional description text
checkedbooleanfalseControlled checked state
onChange(checked: boolean) => void—Change handler
disabledbooleanfalseDisables the checkbox

Radio

Basic Group

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

<Radio name="plan" value="pro" label="Pro Plan" description="$29/month, unlimited features" checked={plan === "pro"} onChange={() => setPlan("pro")} />

Radio Props

PropTypeDefaultDescription
namestring—Radio group name (required)
valuestring—Radio value (required)
labelstring—Radio label
descriptionstring—Additional description text
checkedbooleanfalseControlled checked state
onChange() => void—Change handler
disabledbooleanfalseDisables the radio

Toggle

Basic

<Toggle label="Dark mode" />

With Description

<Toggle label="Auto-save" description="Automatically save changes every 5 minutes" />

States

Controlled

const [enabled, setEnabled] = useState(false); <Toggle label="Notifications" checked={enabled} onChange={setEnabled} />;

Toggle Props

PropTypeDefaultDescription
labelstring—Toggle label
descriptionstring—Additional description text
checkedbooleanfalseControlled checked state
onChange(checked: boolean) => void—Change handler
disabledbooleanfalseDisables 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