Back to Base UIYou are on Radio Group.

Radio Group

Single-choice options with a dot that grows into place.

Available inAvailable in React, Vue, Svelte, Solid, JavaScript· All five frameworks

Libraries

Base UI

Motion

Spring + short tween

Reduced motion

Fade in place
radio-group.tsx
Play with the real component, then read the code it ships with.All components
01

Installation

Installing for React·components/prequelui/radio-group.tsx

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/react/radio-group.json
npmthe default on every machine

First component? Set up your project first

Frameworks

The live preview is React. Each tab below is the file that ships for that framework, with the same durations, springs and reduced-motion rule.

5 runtimes
radio-group.tsx
"use client";

import * as React from "react";
import { motion, useReducedMotion } from "motion/react";
import { cn } from "@/lib/utils";

export type RadioGroupItem = {
  value: string;
  label: string;
  hint?: string;
};

export type RadioGroupProps = {
  items?: RadioGroupItem[];
  value?: string;
  defaultValue?: string;
  onValueChange?: (value: string) => void;
  className?: string;
};

const FALLBACK: RadioGroupItem[] = [
  { value: "standard", label: "Standard", hint: "5–7 business days" },
  { value: "express", label: "Express", hint: "2–3 business days" },
  { value: "overnight", label: "Overnight", hint: "Next business day" },
];

const dot = { type: "spring", stiffness: 200, damping: 16 } as const;
const press = { type: "spring", stiffness: 550, damping: 30 } as const;

export function RadioGroup({
  items = FALLBACK,
  value,
  defaultValue = "standard",
  onValueChange,
  className,
}: RadioGroupProps) {
  const [internal, setInternal] = React.useState(defaultValue);
  const current = value ?? internal;
  const reduce = useReducedMotion();

  const choose = (next: string) => {
    if (value === undefined) setInternal(next);
    onValueChange?.(next);
  };

  return (
    <div role="radiogroup" className={cn("flex flex-col gap-2", className)}>
      {items.map((item) => {
        const active = item.value === current;
        return (
          <motion.button
            key={item.value}
            type="button"
            role="radio"
            aria-checked={active}
            onClick={() => choose(item.value)}
            whileTap={reduce ? undefined : { scale: 0.97 }}
            transition={press}
            className="flex items-center gap-3 rounded-lg border bg-background px-3 py-2.5 text-left text-[13px] transition-colors hover:bg-accent"
          >
            <span className="flex size-4 items-center justify-center rounded-full border">
              <motion.span
                aria-hidden="true"
                animate={reduce ? { scale: active ? 1 : 0 } : { scale: active ? 1 : 0 }}
                transition={reduce ? { duration: 0.15 } : dot}
                className="size-2 rounded-full bg-foreground"
              />
            </span>
            <span className="flex-1">{item.label}</span>
            {item.hint && (
              <span className="text-[13px] text-muted-foreground">{item.hint}</span>
            )}
          </motion.button>
        );
      })}
    </div>
  );
}

Install

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/react/radio-group.json
npmthe default on every machine

Dependencies

motion lucide-react

The registry keeps the component source, its motion tokens and the reduced-motion branch together, so the install never pulls a different animation from the preview.

02

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

radio-group.tsx
import { RadioGroup } from "@/components/prequelui/radio-group";

export default function Demo() {
  return (
    <RadioGroup>
      {/* compose the parts exactly like the underlying primitive */}
    </RadioGroup>
  );
}
import { RadioGroup } from "@/components/prequelui/radio-group";

export function Variant() {
  return (
    <RadioGroup tempo={1.2}>
      …
    </RadioGroup>
  );
}
03

Animation

This primitive keeps the API and semantics of the underlying component and adds motion at the surface edges. Entrances are slower and more settled than exits, so closing never feels like waiting.

  • Springs for position, scale and size; tweens for colour and opacity.
  • The exit is shorter than the entrance, and keeps the current position as its starting point.
  • All measurements are taken again when content or font metrics change.
  • With reduced motion, the surface fades in place and never travels.
spring 300 / 30exit 150 msblur 4 pxheight 450 ms
04

API Reference

Every part takes exactly the props of the Radio Group primitive. The animated surface adds only motion props, so the accessibility tree and keyboard behaviour stay the same.

Radio Group

PropTypeDefault
childrenReactNode—
disabledbooleanfalse
transitionTransitionspring.press
classNamestring—

Next component

Select

A select menu with a gliding highlight and cascading options.