React Radio Group
A React radio group in two styles: glass dots whose pip springs out, or rich option cards where the selection glides from card to card.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/radio-group.jsonRadioGroupRadioRadioCard- +1 more
Using it in a form? See the react-hook-form and zod recipe.
Classic
Each option can carry a description; the legend names the group for screen readers.
How often we send a summary of activity.
import { RadioGroup } from "@/components/sheenui/radio-group/radio-group";
// Package build (after the first npm release, or a packed tarball): import { RadioGroup } from "@sheenui/theme";
export function Example() {
return (
<RadioGroup
label="Email digest"
description="How often we send a summary of activity."
defaultValue="weekly"
items={[
{ value: "daily", label: "Daily", description: "Every morning at 8:00." },
{ value: "weekly", label: "Weekly", description: "Mondays, with the week's highlights." },
{ value: "never", label: "Never", description: "You can still find everything in the app." },
{ value: "hourly", label: "Hourly", description: "Available on Pro.", disabled: true },
]}
/>
);
}Files to copy
5 folders · 6 files · 4 packages
- From
theme/src/ components/radio-group/hooks/{use-latest.ts, use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{cn.ts, form.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/radio-group.jsonRegistry item: radio-group. The styles need the Tailwind v4 glass UI setup.- The examples also use
components/badge/components/button/components/spinner/components/toast/hooks/{use-direction.ts, use-magnetic.ts}motion/gate.tslib/{state-light.tsx, warn-once.ts}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/badge.json https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/toast.json- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Option cards
Cards take an icon, a description and meta such as a price. The selection tint slides to the chosen card (it jumps with reduced motion). Columns follow the group's own width: pricing-style cards side by side when there's room, compact rows on phones.
Selected: Pro
import { useState } from "react";
import { RadioGroup } from "@/components/sheenui/radio-group/radio-group";
// Package build (after the first npm release, or a packed tarball): import { RadioGroup } from "@sheenui/theme";
import { Building2 as BuildingIcon, Rocket as RocketIcon, Sparkles as SparkleIcon } from "lucide-react";
export function Example() {
const [plan, setPlan] = useState("pro");
return (
<RadioGroup
variant="card"
columns={3}
label="Plan"
value={plan}
onValueChange={setPlan}
items={[
{ value: "starter", label: "Starter", description: "For side projects…", icon: <SparkleIcon />, meta: "Free" },
{ value: "pro", label: "Pro", description: "For growing teams…", icon: <RocketIcon />, meta: "$12/mo" },
{ value: "enterprise", label: "Enterprise", description: "SSO, audit logs…", icon: <BuildingIcon />, meta: "Custom" },
]}
/>
);
}Composed cards
Compose RadioCard children for custom content, such as a badge or a delivery estimate.
import { Badge } from "@/components/sheenui/badge/badge";
import { RadioCard, RadioGroup } from "@/components/sheenui/radio-group/radio-group";
// Package build (after the first npm release, or a packed tarball): import { Badge, RadioCard, RadioGroup } from "@sheenui/theme";
import { Zap as BoltIcon, Store as StoreIcon, Truck as TruckIcon } from "lucide-react";
// This example also uses badge: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/badge.json
export function Example() {
return (
<RadioGroup variant="card" columns={1} label="Delivery" defaultValue="standard">
<RadioCard value="standard" label="Standard" description="3–5 working days" icon={<TruckIcon />} meta="Free" />
<RadioCard value="express" label="Express" description="Next working day" icon={<BoltIcon />} meta="$9">
<Badge tone="accent">Order within 4 h 12 min</Badge>
</RadioCard>
<RadioCard value="pickup" label="Pick up in store" description="Out of stock nearby" icon={<StoreIcon />} disabled />
</RadioGroup>
);
}Horizontal, with validation
A required choice in a row (it wraps on small screens). The error is linked to every radio and announced politely when it appears; focus moves to the group so the fix is one key press away.
import { useState, type FormEvent } from "react";
import { Button } from "@/components/sheenui/button/button";
import { RadioGroup } from "@/components/sheenui/radio-group/radio-group";
import { useToast } from "@/components/sheenui/toast/toast";
// Package build (after the first npm release, or a packed tarball): import { Button, RadioGroup, useToast } from "@sheenui/theme";
// This example also uses button, toast: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/toast.json
export function Example() {
const [size, setSize] = useState<string | null>(null);
const [error, setError] = useState<string>();
const toast = useToast();
function submit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
if (!size) {
setError("Choose a size to continue.");
// Take keyboard and screen-reader users straight to the choice.
event.currentTarget.querySelector<HTMLElement>("[role=radio]")?.focus();
return;
}
setError(undefined);
toast.success("Added to bag", `Size ${size.toUpperCase()}`);
}
return (
<form onSubmit={submit} noValidate className="flex flex-col items-start gap-4">
<RadioGroup
label="Size"
orientation="horizontal"
name="size"
required
value={size}
onValueChange={(v) => {
setSize(v);
setError(undefined);
}}
error={error}
items={["xs", "s", "m", "l", "xl"].map((v) => ({ value: v, label: v.toUpperCase() }))}
/>
<Button type="submit">Add to bag</Button>
</form>
);
}RadioGroup
Radio / RadioCard
Keyboard
Accessibility
- role="radiogroup" named by label; each radio is linked to its label and description. error is announced politely and linked to the group.
- RadioCard shows the focus ring on the whole card although the dot holds focus.
- The unchecked ring keeps 3:1 contrast; the touch hit area is 44 px.
When to use the radio group
- Use it as a radio card group for a pricing step where the user must pick exactly one plan, with variant="card" showing an icon, a description and a price in meta for each option.
- Use it for a checkout shipping choice such as Standard or Express, where each option needs a second line of text that a plain dropdown could not show next to the label.
- Use it for a short survey answer or a notification preference, with the classic variant giving a compact dot per option and a legend from the label prop.
- Skip it when the list is long or the choices are many; Select is better, Checkbox suits many-of-many answers, and SegmentedControl suits a few view modes rather than form answers.
- Pair it with Field-style helper text through description and error props, Badge in the meta slot for labels like Popular, and Button to submit the chosen value after name posts it.
Frequently asked questions
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .