Radio Group
Radio group example: circular items with a filled primary checked state and a centered dot indicator. Items get an enlarged hit area and focus, disabled and invalid styling.
pnpm dlx shadcn add @01orbital/radio-group"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"
function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {
return (
<RadioGroupPrimitive
data-slot="radio-group"
className={cn("grid w-full gap-3", className)}
{...props}
/>
)
}
function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) {
return (
<RadioPrimitive.Root
data-slot="radio-group-item"
className={cn(
"group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-transparent bg-input/90 outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",
className
)}
{...props}
>
<RadioPrimitive.Indicator
data-slot="radio-group-indicator"
className="flex size-4 items-center justify-center"
>
<span className="absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground dark:size-2.5" />
</RadioPrimitive.Indicator>
</RadioPrimitive.Root>
)
}
export { RadioGroup, RadioGroupItem }
import { Label } from "@/components/ui/label"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
// The copy: change text here, not in the markup.
const OPTIONS = [
{ value: "default", label: "Default" },
{ value: "comfortable", label: "Comfortable" },
{ value: "compact", label: "Compact" },
] as const
/** Radio Group, after shadcn's example. */
export default function RadioGroupDemo() {
return (
<RadioGroup defaultValue="comfortable" className="w-fit">
{OPTIONS.map((option, i) => (
<div key={option.value} className="flex items-center gap-3">
<RadioGroupItem value={option.value} id={`r${i + 1}`} />
<Label htmlFor={`r${i + 1}`}>{option.label}</Label>
</div>
))}
</RadioGroup>
)
}
Examples
SSO Organization Pickerradio-group-login-sso-picker-01
A searchable list of company identity providers with a required-SSO badge and a continue button that names the chosen provider.
pnpm dlx shadcn add @01orbital/radio-group-login-sso-picker-01"use client"
import { useState } from "react"
import {
ArrowRightIcon,
BuildingsIcon,
ShieldCheckIcon,
} from "@phosphor-icons/react"
import { Title } from "@/components/title/title"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Card, CardContent } from "@/components/ui/card"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
const COPY = {
title: "Sign in with your company",
body: "Pick your organization and we’ll send you to your identity provider.",
search: "Search organizations",
empty: "No organization matches that search.",
submit: "Continue with SSO",
help: "Can’t find yours? Ask your workspace admin for the sign-in link.",
redirecting: (provider: string) => `Redirecting to ${provider}`,
redirectingBody: (org: string) =>
`Signing you in to ${org}. This window will update when you return.`,
back: "Back to organizations",
}
const ORGS = [
{
name: "Northwind Logistics",
domain: "northwind.example",
provider: "Okta",
enforced: true,
},
{
name: "Halcyon Health",
domain: "halcyon.example",
provider: "Microsoft Entra ID",
enforced: true,
},
{
name: "Brightline Studio",
domain: "brightline.example",
provider: "Google Workspace",
enforced: false,
},
{
name: "Tern Capital",
domain: "terncapital.example",
provider: "OneLogin",
enforced: true,
},
{
name: "Quarry & Co",
domain: "quarry.example",
provider: "Okta",
enforced: false,
},
] as const
export default function LoginSsoPicker01() {
const [query, setQuery] = useState("")
const [redirecting, setRedirecting] = useState(false)
const [selected, setSelected] = useState<string | null>(ORGS[0].name)
const results = ORGS.filter((org) =>
`${org.name} ${org.domain}`
.toLowerCase()
.includes(query.trim().toLowerCase())
)
const current = ORGS.find((org) => org.name === selected)
if (redirecting && current) {
return (
<div className="flex min-h-[640px] w-full items-center justify-center bg-muted/40 px-4 py-12">
<Card className="w-full max-w-md">
<CardContent className="flex flex-col gap-4 px-6 sm:px-8">
<Title render={<h2 aria-live="polite" />}>
{COPY.redirecting(current.provider)}
</Title>
<p className="text-sm text-muted-foreground">
{COPY.redirectingBody(current.name)}
</p>
<Button variant="outline" onClick={() => setRedirecting(false)}>
{COPY.back}
</Button>
</CardContent>
</Card>
</div>
)
}
return (
<div className="flex min-h-[640px] w-full items-center justify-center bg-muted/40 px-4 py-12">
<Card className="w-full max-w-md">
<CardContent className="flex flex-col gap-6 px-6 sm:px-8">
<div className="flex flex-col gap-2">
<span className="flex size-10 items-center justify-center rounded-2xl bg-muted text-foreground">
<BuildingsIcon className="size-5" weight="duotone" />
</span>
<Title render={<h2 />}>{COPY.title}</Title>
<p className="text-sm text-muted-foreground">{COPY.body}</p>
</div>
<Input
type="search"
value={query}
onChange={(event) => setQuery(event.target.value)}
placeholder={COPY.search}
aria-label={COPY.search}
/>
<RadioGroup
aria-label={COPY.title}
value={selected ?? ""}
onValueChange={setSelected}
className="flex flex-col gap-2"
>
{results.map((org) => {
return (
<Label
key={org.name}
htmlFor={`sso-${org.name}`}
className="flex cursor-pointer items-center gap-3 rounded-2xl border border-border px-3.5 py-3 text-left font-normal transition-colors hover:bg-muted/50 has-data-checked:border-foreground/30 has-data-checked:bg-muted"
>
<span className="flex size-9 shrink-0 items-center justify-center rounded-xl bg-background text-sm font-semibold ring-1 ring-foreground/10">
{org.name[0]}
</span>
<span className="min-w-0 flex-1">
<span className="flex items-center gap-2">
<span className="truncate text-sm font-medium">
{org.name}
</span>
{org.enforced ? (
<Badge variant="secondary" className="gap-1">
<ShieldCheckIcon className="size-3" />
Required
</Badge>
) : null}
</span>
<span className="block truncate text-xs text-muted-foreground">
{org.domain} · {org.provider}
</span>
</span>
<RadioGroupItem id={`sso-${org.name}`} value={org.name} />
</Label>
)
})}
{results.length === 0 ? (
<p className="py-6 text-center text-sm text-muted-foreground">
{COPY.empty}
</p>
) : null}
</RadioGroup>
<Button
size="lg"
disabled={!current}
className="w-full"
onClick={() => setRedirecting(true)}
>
{current ? `${COPY.submit} (${current.provider})` : COPY.submit}
<ArrowRightIcon data-icon="inline-end" />
</Button>
<p className="text-center text-xs text-muted-foreground">
{COPY.help}
</p>
</CardContent>
</Card>
</div>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: the card, panel or column that holds it is the
// measure. text-pretty keeps a wrapped title from ending on one word.
/**
* The title of a card, panel or list group, rendered as an `<h3>` in the body
* font: 18px with a 28px line, 20px from the `sm` breakpoint, medium weight.
* One size, no props beyond the element's own; pass `render` to use another
* heading level. Inside a stock `Card`, use `CardTitle`; a section's heading
* is `Subheading` and a page's headline is `Heading`.
*/
function Title({
className,
render,
...props
}: useRender.ComponentProps<"h3">) {
return useRender({
defaultTagName: "h3",
render,
state: { slot: "title" },
props: mergeProps<"h3">(
{
className: cn(
"text-lg/7 font-medium tracking-tight text-pretty sm:text-xl/7",
className
),
},
props
),
})
}
export { Title }
Radio Group components
The library's own radio group components, each installed on its own.
Orb Pickerorb-picker
Orb color chooser: a radio group where every row shows its colorway as a planet with a name and note, and arrow keys move the choice. Lists the Orb Palettes by default; pair it with the Voice Orb to let people pick an assistant's color. Open its docs page
pnpm dlx shadcn add @01orbital/orb-pickerThe source comes with full access.
One payment of $149 opens the source right here and lets the CLI install every paid component, with lifetime updates.
Dependencies
npm: @base-ui/react, cn. The CLI installs them for you. cn merges Tailwind class names, in place of clsx and tailwind-merge.
Used in blocks
2 blocks are built with Radio Group: