Components

Radio Group

An animated React radio group built on shadcn/ui and Radix: the drop-in RadioGroup scales its dot in and turns mint when checked — plus Radio Cards, selectable plan and pricing cards whose outline glides to the chosen card with Motion.

  • Drop-in shadcn API
  • Radix Radio Group
  • CSS transitions
  • Motion layoutId
  • prefers-reduced-motion

Installation

$ npx shadcn@latest add https://duskui.com/r/radio-group.json

Replaces components/ui/radio-group.tsx with the same parts and data-slot attributes. The dot animates with a CSS transition, so there is no JavaScript per frame.

Usage

density.tsx
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"

export function Density() {
  return (
    <RadioGroup defaultValue="comfortable" aria-label="Density">
      <div className="flex items-center gap-3">
        <RadioGroupItem value="comfortable" id="comfortable" />
        <label htmlFor="comfortable">Comfortable</label>
      </div>
      <div className="flex items-center gap-3">
        <RadioGroupItem value="compact" id="compact" />
        <label htmlFor="compact">Compact</label>
      </div>
    </RadioGroup>
  )
}

Examples

Default

Pick an option to watch the dot scale in while the previous one shrinks away. Arrow keys move the selection.

With descriptions

Wrap the group in a fieldset with a legend, and link each hint with aria-describedby. name submits the value with a form.

Notify me about…

Every message in every channel.

Only when someone needs you.

Mute notifications on this device.

Horizontal, disabled & invalid

Lay items out in a row with orientation="horizontal" (Left / Right arrows), disable single items, and mark errors with aria-invalid.

Please choose an option.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Radio Cards

Selectable cards for plans, pricing tiers or shipping speeds. A 1px primary outline glides from card to card via a shared Motion layoutId. The whole card is the click target, and it is still a Radix radio group, so arrow keys and forms work.

$ npx shadcn@latest add https://duskui.com/r/radio-cards.json
PropTypeDefaultDescription
value / onValueChangestring / (value: string) => void—Controlled selection (on RadioCards).
defaultValuestring—Uncontrolled initial selection.
name / required / disabled / orientationRadix RadioGroup props—Forwarded to the Radix root.
classNamestring—On RadioCards: it is a CSS grid, e.g. grid-cols-3.
RadioCard › titleReactNode—Card title; names the radio.
RadioCard › descriptionReactNode—Secondary text; describes the radio.
RadioCard › icon / asideReactNode—Leading icon and right-aligned content such as a price.
RadioCard › childrenReactNode—Extra content under the description (features, badges).
RadioCard › containerClassNamestring—Classes for the card. `className` styles the radio.

Radio Cards — grid

The same block in a three-column grid (className="sm:grid-cols-3"). The outline travels across the row, and the cards stack on small screens.

$ npx shadcn@latest add https://duskui.com/r/radio-cards.json

API Reference

Same parts as shadcn/ui: RadioGroup and RadioGroupItem, each forwarding its Radix Radio Group props.

PropTypeDefaultDescription
value / onValueChangestring / (value: string) => void—Controlled selection (on RadioGroup).
defaultValuestring—Uncontrolled initial selection.
name / requiredstring / boolean—Form integration on RadioGroup.
orientation"horizontal" | "vertical"—Which arrow keys move the selection.
loopbooleantrueWrap around at the ends.
value / disabledstring / boolean—On RadioGroupItem.

Accessibility

  • Built on Radix Radio Group: a radiogroup with radio items, roving focus (one Tab stop) and arrow keys that move the selection.
  • Give the group a name with aria-label, aria-labelledby or a fieldset legend, and pair each item with a <label htmlFor>.
  • Radio Cards name each radio by its title (aria-labelledby) and describe it with the description (aria-describedby); the card is a <label>, so clicking anywhere selects.
  • The gliding outline is decorative (aria-hidden); the checked state is conveyed by aria-checked.
  • Under prefers-reduced-motion the dot appears instantly and the outline jumps instead of gliding.