Copy to clipboard
Installation
Copy to clipboard
npx bearnie add radio
npx bearnie add radio
bunx bearnie add radio
bunx bearnie add radio
pnpm dlx bearnie add radio
pnpm dlx bearnie add radio
yarn dlx bearnie add radio
yarn dlx bearnie add radio
Copy to clipboard
import RadioGroup from "@/components/ui/radio/RadioGroup.astro";
import RadioGroupItem from "@/components/ui/radio/RadioGroupItem.astro";
Usage
import { RadioGroup, RadioGroupItem } from "@/components/ui"
<RadioGroup name="options" defaultValue="one">
<div class="flex items-center gap-3">
<RadioGroupItem value="one" id="option-one" />
<Label for="option-one">Option One</Label>
</div>
<div class="flex items-center gap-3">
<RadioGroupItem value="two" id="option-two" />
<Label for="option-two">Option Two</Label>
</div>
</RadioGroup>
Examples
Horizontal
Copy to clipboard
With description
Copy to clipboard
Default spacing for most users.
Reduced spacing for power users.
Disabled
Copy to clipboard
Card style
Copy to clipboard
TeamFor small teams
Standalone Radio
Copy to clipboard
Anatomy
RadioGroup- Container that manages the radio group stateRadioGroupItem- Individual radio button within a groupRadio- Standalone radio input for simple use cases
Props
RadioGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| name | string | - | Required. Groups radio buttons together |
| defaultValue | string | - | Initially selected value |
| disabled | boolean | false | Disables all items in the group |
| required | boolean | false | Makes selection required |
| orientation | ”horizontal” | “vertical" | "vertical” | Layout direction |
| class | string | - | Additional CSS classes |
RadioGroupItem
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Required. Form value when selected |
| id | string | - | Element ID for label association |
| disabled | boolean | false | Disables this item |
| checked | boolean | false | Controlled checked state |
| class | string | - | Additional CSS classes |
Radio
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | - | Element ID for label association |
| name | string | - | Groups radio buttons together |
| value | string | - | Form value when selected |
| checked | boolean | false | Default checked state |
| disabled | boolean | false | Disables the radio |
| required | boolean | false | Makes selection required |
| class | string | - | Additional CSS classes |