Quick search...K

    Radio

    A component for displaying radios.

    Selected Value: option1

    Usage Examples

    Basic Usage

    A simple usage of RadioGroup with RadioGroupItem components.

    <RadioGroup value={selectedValue} onValueChange={setSelectedValue}>
    <RadioGroupItem value="option1" id="option1" />
    <RadioGroupItem value="option2" id="option2" />
    <RadioGroupItem value="option3" id="option3" />
    </RadioGroup>

    With Labels

    Add labels to each radio button for accessibility and better UX.

    <RadioGroup value={selectedValue} onValueChange={setSelectedValue}>
    <div className="flex gap-4">
      <RadioGroupItem value="option1" id="option1" />
      <label htmlFor="option1" className="mt-1">Option 1</label>
    
      <RadioGroupItem value="option2" id="option2" />
      <label htmlFor="option2" className="mt-1">Option 2</label>
    
      <RadioGroupItem value="option3" id="option3" />
      <label htmlFor="option3" className="mt-1">Option 3</label>
    </div>
    </RadioGroup>

    Disabled Group

    Make the entire RadioGroup (and its items) disabled by using the `disabled` prop.

    <RadioGroup value={selectedValue} onValueChange={setSelectedValue} disabled>
    <RadioGroupItem value="option1" id="option1" />
    <RadioGroupItem value="option2" id="option2" />
    <RadioGroupItem value="option3" id="option3" />
    </RadioGroup>