Skip to content

Radio Group

Single choice from a set of options.

Installation

bun add @xerobi/ui
import { RadioGroup, RadioGroupItem } from "@xerobi/ui/radio-group"

This component is client-side. In Astro, hydrate it with a client directive.

Examples

Default

import { RadioGroup, RadioGroupItem } from "@xerobi/ui/radio-group"

export function RadioGroupDefault() {
  return (
    <RadioGroup defaultValue="one" aria-label="Select option">
      <div className="flex items-center gap-2">
        <RadioGroupItem value="one" id="option-one" />
        <label htmlFor="option-one" className="text-body2">Option 1</label>
      </div>
      <div className="flex items-center gap-2">
        <RadioGroupItem value="two" id="option-two" />
        <label htmlFor="option-two" className="text-body2">Option 2</label>
      </div>
    </RadioGroup>
  )
}

API reference

RadioGroup

Also accepts every prop of Base UI RadioGroup.

No props of its own.

RadioGroupItem

Also accepts every prop of Base UI Radio.

No props of its own.

Styling hooks: [data-slot="radio-group"], [data-slot="radio-group-item"], [data-slot="radio-group-indicator"].

Search documentation

Search pages, components and blocks.