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

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

PropTypeDefaultDescription
labelstring—Checkbox label
descriptionstring—Additional description text
checkedbooleanfalseControlled checked state
onChangeChangeEventHandler<HTMLInputElement>—Native change handler; read e.target.checked
disabledbooleanfalseDisables 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

PropTypeDefaultDescription
namestring—Radio group name (required)
valuestring—Radio value (required)
labelstring—Radio label
descriptionstring—Additional description text
checkedbooleanfalseControlled checked state
onChangeChangeEventHandler<HTMLInputElement>—Native change handler
disabledbooleanfalseDisables 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

PropTypeDefaultDescription
labelstring—Toggle label
descriptionstring—Additional description text
checkedbooleanfalseControlled checked state
onChangeChangeEventHandler<HTMLInputElement>—Native change handler; read e.target.checked
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