Skip to content
synccn

Radio Group

Pick one option, shown as dots or as selectable cards.

Installation

$ pnpm dlx shadcn@latest add @synccn/radio-group

First time in this project? Connect synccn with one command.

Usage

import { RadioGroup } from "@/components/ui/radio-group";<RadioGroup variant="cards" options={plans} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

RadioGroup

options: [{ value, label, description?, disabled? }] variant "default" renders dots, "cards" renders selectable tiles.

  • optionsrequired
    RadioOption[]

    Choices.

  • value
    string

    Controlled value.

  • defaultValue
    string

    Initial value when uncontrolled. Defaults to the first option.

  • onValueChange
    (value: string) => void

    Called with the new value.

  • variant
    "default" | "cards"

    Default "default"

    Dots or selectable cards.

  • name
    string

    Accessible name if no label is given.

  • label
    string

    Accessible name for the group.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseControllable (works controlled or uncontrolled)

npm packages

Keyboard

  • ↓or→Select the next option
  • ↑or←Select the previous option
  • TabLeave the group

Accessibility

  • Only the selected radio is in the tab order, as in a native radio group.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: radio, radiogroup
  • ARIA attributes: aria-checked, aria-label
  • Keys handled: ArrowUp, ArrowDown, ArrowLeft, ArrowRight
  • Shows a visible focus ring for keyboard users
  • Labels are tied to their controls