8.4k

Radio Group

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

API Reference

Installation

pnpm dlx shadcn@latest add https://coss.com/ui/r/radio-group.json

Usage

import { Label } from "@/components/ui/label"
import { Radio, RadioGroup } from "@/components/ui/radio-group"
<RadioGroup defaultValue="next">
  <Label>
    <Radio value="next" /> Next.js
  </Label>
  <Label>
    <Radio value="vite" /> Vite
  </Label>
  <Label>
    <Radio value="astro" /> Astro
  </Label>
</RadioGroup>

Examples

For accessible labelling and validation, prefer using the Field component to wrap radio buttons. See the related example: Radio Group field.

Disabled

With Description

Card Style

Form Integration

Comparing with Radix / shadcn

If you’re already familiar with Radix UI and shadcn/ui, this guide highlights the small differences and similarities so you can get started with coss.com ui quickly.

Quick Checklist

  • Use Radio going forward; RadioGroupItem remains for legacy
  • If you used asChild on parts, switch to the render prop

coss.com ui

Built by and for the team of Cal.com, Inc. — the leading commercial open source company (“coss”).