120k

Radio Group

A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time.

Installation

pnpm dlx shadcn@latest add @force-ui-vue/radio-group

Usage

<script setup lang="ts">
import { Label } from "@/components/ui/label"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
</script>
<template>
  <RadioGroup default-value="option-one">
    <div class="flex items-center gap-3">
      <RadioGroupItem id="option-one" value="option-one" />
      <Label for="option-one">Option One</Label>
    </div>
    <div class="flex items-center gap-3">
      <RadioGroupItem id="option-two" value="option-two" />
      <Label for="option-two">Option Two</Label>
    </div>
  </RadioGroup>
</template>

Composition

Use the following composition to build a RadioGroup:

RadioGroup
├── RadioGroupItem
└── RadioGroupItem

Examples

Description

Radio group items with a description using the Field component.

Choice Card

Use FieldLabel to wrap the entire Field for a clickable card-style selection.

Fieldset

Use FieldSet and FieldLegend to group radio items with a label and description.

Disabled

Use the disabled prop on RadioGroupItem to disable individual items.

Invalid

Use aria-invalid on RadioGroupItem and data-invalid on Field to show validation errors.

RTL

To enable RTL support in Force UI, see the RTL configuration guide.

API Reference

See the Radix UI Radio Group documentation.