- Accordion
- Agent Thinking
- Alert
- Alert Dialog
- Announcement
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Checkbox
- Checkbox Card
- Code Block
- Collapsible
- Color Picker
- Combobox
- Command
- Composer
- Composer Loader
- Context Menu
- Data Grid
- Data Table
- Date Picker
- Dialog
- Direction
- Drawer
- Dropdown Menu
- Empty
- Field
- File Upload
- Hover Card
- Input
- Input Group
- Input Otp
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Meter
- Native Select
- Navigation Menu
- Number Field
- Pagination
- Period Switcher
- Popover
- Progress
- Questionnaire
- Radio Card
- Radio Group
- Resizable
- Reveal
- Scroll Area
- Search Field
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Social Button
- Sonner
- Spinner
- Status Dot
- Switch
- Switch Card
- Table
- Tabs
- Tag Group
- Textarea
- Theme Toggle
- Time Field
- Toggle
- Toggle Group
- Tooltip
- Trace
- Tree View
- Agent Creator 01
- Agent Limits Card 01
- Agent Progress 01
- AI Chat 01
- AI Image Generation 01
- AI Profile 01
- Alerts Card 01
- Auth Card 01
- Calendar 01
- Composer 01
- Composer Attachments 01
- Composer Panel 01
- Finance Dashboard 01
- Home Dashboard 01
- Marketing Dashboard 01
- Medical Profile 01
- Meeting Scheduler 01
- Multi Agent Chat 01
- Notification Center 01
- Patient Info Card 01
- Project Board 01
- Questionnaire 01
- Settings Modal 01
- Sidebar 01
- Stat Cards 01
- Task List 01
- Web Search 01
- Activity Rings Card 01
- Area Chart Card 01
- Bar List Card 01
- Combo Chart Card 01
- Contributions Card 01
- Earnings Chart Card 01
- Funnel Chart Card 01
- Heatmap Chart Card 01
- Line Chart Card 01
- Most Active Days Card 01
- Orders Chart Card 01
- Radar Chart Card 01
- Radial Chart Card 01
- Revenue Chart Card 01
- Sankey Chart Card 01
- Scatter Chart Card 01
- Sleep Score Card 01
- Stage Bars Card 01
- Steps Card 01
Installation
$ pnpm dlx shadcn@latest add @cobalt/radio-group
Sizes
default is 16px and sm is 14px. Arrow keys move the selection inside a group.
md - 16px
sm - 14px
Source
"use client";
import { Radio as RadioPrimitive } from "@base-ui/react/radio";
import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group";
import { cn } from "cn";
/**
* Set `data-pointer-open` on the group (or an ancestor) to hide the focus ring
* on its items. A popover opened with the mouse focuses an item from script and
* Chrome then reports `:focus-visible` if a key was pressed earlier. Remove the
* attribute on the first key press so keyboard focus stays visible.
*/
function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {
return (
<RadioGroupPrimitive
data-slot="radio-group"
className={cn("grid w-full gap-2", className)}
{...props}
/>
);
}
function RadioGroupItem({
className,
size = "default",
...props
}: RadioPrimitive.Root.Props & { size?: "default" | "sm" }) {
return (
<RadioPrimitive.Root
data-slot="radio-group-item"
data-size={size}
className={cn(
"group/radio-group-item peer relative flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-full outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background in-data-[pointer-open]:focus-visible:ring-0 in-data-[pointer-open]:focus-visible:ring-offset-0 data-disabled:cursor-not-allowed data-disabled:opacity-50 aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=sm]:size-3.5",
className
)}
{...props}
>
<span className="absolute inset-0 rounded-full border border-[var(--border-strong,var(--input))] bg-popover shadow-[shadow:var(--shadow-control,0_1px_2px_0_rgb(0_0_0/0.05))] transition-opacity duration-200 ease-[ease] motion-reduce:transition-none group-data-checked/radio-group-item:opacity-0 group-data-[size=sm]/radio-group-item:border-[0.875px]" />
<span className="absolute inset-0 rounded-full bg-primary bg-[image:var(--gradient-button-primary-default,linear-gradient(180deg,oklch(from_var(--primary)_calc(l_+_0.08)_c_h),var(--primary)))] opacity-0 shadow-[inset_0_0_0_1px_oklch(from_var(--primary)_calc(l_+_0.08)_c_h),inset_0_2px_0_0_rgb(255_255_255/0.25)] transition-opacity duration-200 ease-[ease] motion-reduce:transition-none group-data-checked/radio-group-item:opacity-100 group-data-[size=sm]/radio-group-item:shadow-[inset_0_0_0_0.875px_oklch(from_var(--primary)_calc(l_+_0.08)_c_h),inset_0_1.75px_0_0_rgb(255_255_255/0.25)]" />
<RadioPrimitive.Indicator
keepMounted
data-slot="radio-group-indicator"
className="absolute top-1/2 left-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 scale-0 rounded-full bg-primary-foreground opacity-0 transition-[scale,opacity] duration-200 ease-[ease] data-checked:scale-100 data-checked:opacity-100 motion-reduce:transition-none group-data-[size=sm]/radio-group-item:size-[5px]"
/>
</RadioPrimitive.Root>
);
}
export { RadioGroup, RadioGroupItem }; On this page