A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time.
Epicenter
Local-first, open source apps
Installation
Install bits-ui:
Copy and paste the following code into your project.
Usage
<script lang="ts">
import { Label } from "$lib/components/ui/label/index.js";
import * as RadioGroup from "$lib/components/ui/radio-group/index.js";
</script> <RadioGroup.Root value="option-one">
<div class="flex items-center gap-3">
<RadioGroup.Item value="option-one" id="option-one" />
<Label for="option-one">Option One</Label>
</div>
<div class="flex items-center gap-3">
<RadioGroup.Item value="option-two" id="option-two" />
<Label for="option-two">Option Two</Label>
</div>
</RadioGroup.Root> Description
Radio group items with a description using the Field component.
Standard spacing for most use cases.
More space between elements.
Minimal spacing for dense layouts.
Choice Card
Use Field.Label to wrap the entire Field.Field for a clickable card-style selection.
Fieldset
Use Field.Set and Field.Legend to group radio items with a label and description.
Disabled
Use the disabled prop on RadioGroup.Item to disable individual items.
Invalid
Use aria-invalid on RadioGroup.Item and data-invalid on Field.Field to show validation errors.