Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Menubar
- Message
- Meter
- Number Field
- OTP Field
- Pagination
- Popover
- Preview Card
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Toolbar
- Tooltip
Shared
- Artifact
- Audio Player
- Canvas
- Chain of Thought
- Checkpoint
- Code Block
- Commit
- Connection
- Context
- Controls
- Edge
- Environment Variables
- Mic Selector
- Model Selector
- Node
- Node Toolbar
- Open in Chat
- Panel
- Plan
- Prompt Input
- Queue
- Reasoning
- Sandbox
- Schema Display
- Shimmer
- Snippet
- Sources
- Speech Input
- Stack Trace
- Suggestion
- Tool
- Transcription
- Web Preview
Hooks
Resources
Radio Group
A set of checkable buttons where no more than one of the buttons can be checked at a time.
import { Label } from "@/components/ui/label";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
export default function Particle() {
return (
<RadioGroup defaultValue="next">
<Label>
<RadioGroupItem value="next" /> Next.js
</Label>
<Label>
<RadioGroupItem value="vite" /> Vite
</Label>
<Label>
<RadioGroupItem value="astro" /> Astro
</Label>
</RadioGroup>
);
}
Installation
pnpm dlx shadcn@latest add @frontal-labs/radio-group
Usage
import { Label } from "@/components/ui/label";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";<RadioGroup defaultValue="next">
<Label>
<RadioGroupItem value="next" /> Next.js
</Label>
<Label>
<RadioGroupItem value="vite" /> Vite
</Label>
<Label>
<RadioGroupItem value="astro" /> Astro
</Label>
</RadioGroup>API Reference
RadioGroup
Root component. Styled wrapper for RadioGroup from Base UI, laid out as a full-width grid with a gap-2.
RadioGroupItem
Individual radio button. Styled wrapper for Radio.Root from Base UI with a built-in indicator.
In light mode the control carries a bg-muted fill on top of its border, so an unselected radio stays visible against a white surface instead of relying on the border alone.
Examples
For accessible labelling and validation, prefer using the Field component to wrap radio buttons. See the related example: Radio Group field.
Disabled
import { Label } from "@/components/ui/label";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
export default function Particle() {
return (
<RadioGroup defaultValue="next">
<Label>
<RadioGroupItem value="next" /> Next.js
</Label>
<Label>
<RadioGroupItem disabled value="vite" /> Vite (disabled)
</Label>
<Label>
<RadioGroupItem value="astro" /> Astro
</Label>
</RadioGroup>
);
}
With Description
Basic features for personal use.
Advanced tools for professionals.
import { Label } from "@/components/ui/label";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
export default function Particle() {
return (
<RadioGroup defaultValue="r-1">
<div className="flex items-start gap-2">
<RadioGroupItem id="r-1" value="r-1" />
<div className="flex flex-col gap-1">
<Label htmlFor="r-1">Free</Label>
<p className="text-muted-foreground text-xs">Basic features for personal use.</p>
</div>
</div>
<div className="flex items-start gap-2">
<RadioGroupItem id="r-2" value="r-2" />
<div className="flex flex-col gap-1">
<Label htmlFor="r-2">Pro</Label>
<p className="text-muted-foreground text-xs">Advanced tools for professionals.</p>
</div>
</div>
</RadioGroup>
);
}
Card Style
import { Label } from "@/components/ui/label";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
export default function Particle() {
return (
<RadioGroup defaultValue="r-1">
<Label className="flex items-start gap-2 rounded-md border p-3 hover:bg-accent/50 has-data-checked:border-primary/48 has-data-checked:bg-accent/50">
<RadioGroupItem value="r-1" />
<div className="flex flex-col gap-1">
<p>Email</p>
<p className="text-muted-foreground text-xs">Receive notifications via email.</p>
</div>
</Label>
<Label className="flex items-start gap-2 rounded-md border p-3 hover:bg-accent/50 has-data-checked:border-primary/48 has-data-checked:bg-accent/50">
<RadioGroupItem value="r-2" />
<div className="flex flex-col gap-1">
<p>SMS</p>
<p className="text-muted-foreground text-xs">Receive notifications via text message.</p>
</div>
</Label>
</RadioGroup>
);
}
Form Integration
"use client";
import type { FormEvent } from "react";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { Field, FieldLabel } from "@/components/ui/field";
import { Fieldset, FieldsetLegend } from "@/components/ui/fieldset";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import { Spinner } from "@/components/ui/spinner";
export default function Particle() {
const [loading, setLoading] = useState(false);
const onSubmit = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
const formData = new FormData(e.currentTarget);
setLoading(true);
await new Promise((r) => setTimeout(r, 800));
setLoading(false);
alert(`Selected: ${formData.get("frameworks")}`);
};
return (
<form className="flex w-full max-w-[160px] flex-col gap-4" onSubmit={onSubmit}>
<Fieldset className="gap-2">
<FieldsetLegend className="font-medium text-sm">Frameworks</FieldsetLegend>
<RadioGroup defaultValue="next">
<Field orientation="horizontal">
<FieldLabel>
<RadioGroupItem value="next" /> Next.js
</FieldLabel>
</Field>
<Field orientation="horizontal">
<FieldLabel>
<RadioGroupItem value="vite" /> Vite
</FieldLabel>
</Field>
<Field orientation="horizontal">
<FieldLabel>
<RadioGroupItem value="astro" /> Astro
</FieldLabel>
</Field>
</RadioGroup>
</Fieldset>
<Button disabled={loading} type="submit">
{loading && <Spinner />}
Submit
</Button>
</form>
);
}