A Radix select with a sized trigger, popper-positioned menu, scroll buttons, groups, labels, separators and a check indicator on the chosen item.
What changed
- 1.0.2 Oct 11, 2026Switch track, thumb travel, and checkbox and radio size follow the platform feel tokens (--bm-switch-*, --bm-check-size); select and command surfaces take the feel's frosting. Unchanged without a feel.
- 1.0.1 Oct 11, 2026Control heights, menu and sidebar row sizes, press dimming and frosted surfaces follow the platform feel tokens (--bm-control-h, --bm-menu-*, --bm-sidebar-*, --bm-material-*). Unchanged without a feel.
- 1.0.0 Sep 28, 2026First release.
import { Label } from "@/components/ballmac/label"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ballmac/select"
export default function SelectDemo() {
return (
<div className="grid w-full max-w-xs gap-2">
<Label htmlFor="role">Role</Label>
<Select defaultValue="editor">
<SelectTrigger id="role" className="w-full">
<SelectValue placeholder="Choose a role" />
</SelectTrigger>
<SelectContent>
<SelectItem value="owner">Owner</SelectItem>
<SelectItem value="admin">Admin</SelectItem>
<SelectItem value="editor">Editor</SelectItem>
<SelectItem value="viewer">Viewer</SelectItem>
<SelectItem value="billing" disabled>
Billing (upgrade to add)
</SelectItem>
</SelectContent>
</Select>
</div>
)
}Installation
The default, and what a Radix-style project installs.
$ pnpm dlx shadcn@latest add @ballmac/selectInstall the dependencies.
$ pnpm add radix-ui lucide-reactAdd the Ballmac items it builds on.
$ pnpm dlx shadcn@latest add @ballmac/directionCopy the source into your project.
components/ballmac/select.tsx// Ballmac UI: Select. https://ui.ballmac.com/components/select // Based on shadcn/ui's Select (MIT, Copyright (c) 2023 shadcn), restyled with trigger sizes and tw-animate-css transitions. "use client" import * as React from "react" import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react" import { Select as SelectPrimitive } from "radix-ui" import { useDirection } from "@/lib/ballmac/direction" import { cn } from "@/lib/utils" function Select(props: React.ComponentProps<typeof SelectPrimitive.Root>) { const dir = useDirection(props.dir) return <SelectPrimitive.Root data-slot="select" dir={dir} {...props} /> } function SelectGroup(props: React.ComponentProps<typeof SelectPrimitive.Group>) { return <SelectPrimitive.Group data-slot="select-group" {...props} /> } function SelectValue(props: React.ComponentProps<typeof SelectPrimitive.Value>) { return <SelectPrimitive.Value data-slot="select-value" {...props} /> } type SelectTriggerProps = React.ComponentProps<typeof SelectPrimitive.Trigger> & { /** Matches Input and Button heights: sm is h-8, default is h-9. */ size?: "sm" | "default" } function SelectTrigger({ className, size = "default", children, ...props }: SelectTriggerProps) { return ( <SelectPrimitive.Trigger data-slot="select-trigger" data-size={size} className={cn( "flex w-fit min-w-0 items-center justify-between gap-2 whitespace-nowrap rounded-md border border-input bg-background px-3 text-sm text-foreground shadow-xs outline-none transition-[color,border-color,box-shadow] duration-150 dark:bg-input/30 dark:hover:bg-input/50", "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20", "disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground", "data-[size=default]:h-[var(--bm-control-h,calc(var(--spacing)*9))] data-[size=sm]:h-[var(--bm-control-h-sm,calc(var(--spacing)*8))] data-[size=sm]:px-2.5 data-[size=sm]:text-[13px]", "*:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground", className )} {...props} > {children} <SelectPrimitive.Icon className="flex"> <ChevronDownIcon className="size-4 opacity-60" aria-hidden="true" /> </SelectPrimitive.Icon> </SelectPrimitive.Trigger> ) } type SelectContentProps = React.ComponentProps<typeof SelectPrimitive.Content> & { /** "popper" opens below the trigger like a menu; "item-aligned" overlaps the trigger like a native select. */ position?: "popper" | "item-aligned" /** Distance in px from the trigger when position is "popper". */ sideOffset?: number } function SelectContent({ className, children, position = "popper", align = "start", sideOffset = 4, ...props }: SelectContentProps) { return ( <SelectPrimitive.Portal> <SelectPrimitive.Content data-slot="select-content" position={position} align={align} sideOffset={position === "popper" ? sideOffset : undefined} className={cn( "relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border bg-popover/[var(--bm-material-alpha,100%)] backdrop-blur-[var(--bm-material-blur,0px)] text-popover-foreground shadow-[0_8px_24px_-6px_rgb(0_0_0/0.18),0_2px_6px_-2px_rgb(0_0_0/0.08)]", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 motion-reduce:animate-none", "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className )} {...props} > <SelectScrollUpButton /> <SelectPrimitive.Viewport className={cn( "p-1", position === "popper" && "h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width) scroll-my-1" )} > {children} </SelectPrimitive.Viewport> <SelectScrollDownButton /> </SelectPrimitive.Content> </SelectPrimitive.Portal> ) } function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Label>) { return ( <SelectPrimitive.Label data-slot="select-label" className={cn("px-2 pt-2 pb-1 text-xs font-medium text-muted-foreground", className)} {...props} /> ) } function SelectItem({ className, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Item>) { return ( <SelectPrimitive.Item data-slot="select-item" className={cn( "relative flex w-full cursor-default select-none items-center gap-2 rounded-md py-1.5 pe-8 ps-2 text-sm outline-hidden", "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground", "*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className )} {...props} > <span data-slot="select-item-indicator" className="absolute end-2 flex size-3.5 items-center justify-center"> <SelectPrimitive.ItemIndicator> <CheckIcon className="size-4 text-foreground" aria-hidden="true" /> </SelectPrimitive.ItemIndicator> </span> <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText> </SelectPrimitive.Item> ) } function SelectSeparator({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Separator>) { return ( <SelectPrimitive.Separator data-slot="select-separator" className={cn("pointer-events-none -mx-1 my-1 h-px bg-border", className)} {...props} /> ) } function SelectScrollUpButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) { return ( <SelectPrimitive.ScrollUpButton data-slot="select-scroll-up-button" className={cn("flex cursor-default items-center justify-center py-1 text-muted-foreground", className)} {...props} > <ChevronUpIcon className="size-4" aria-hidden="true" /> </SelectPrimitive.ScrollUpButton> ) } function SelectScrollDownButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) { return ( <SelectPrimitive.ScrollDownButton data-slot="select-scroll-down-button" className={cn("flex cursor-default items-center justify-center py-1 text-muted-foreground", className)} {...props} > <ChevronDownIcon className="size-4" aria-hidden="true" /> </SelectPrimitive.ScrollDownButton> ) } export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, type SelectContentProps, type SelectTriggerProps, }Update the import paths to match your project setup.
$ pnpm dlx shadcn@latest add https://ui.ballmac.com/r/base/select.jsonInstall the dependencies.
$ pnpm add lucide-react @base-ui/react@^1.9.0Add the Ballmac items it builds on (their Base UI versions where they have one).
$ pnpm dlx shadcn@latest add https://ui.ballmac.com/r/base/direction.json https://ui.ballmac.com/r/base/positioner.jsonCopy the source into your project.
components/ballmac/select.tsx// Ballmac UI: Select. https://ui.ballmac.com/components/select // Based on shadcn/ui's Select (MIT, Copyright (c) 2023 shadcn), restyled with trigger sizes and tw-animate-css transitions. "use client" import * as React from "react" import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react" import { Select as SelectPrimitive } from "@base-ui/react/select" import { DirectionProvider, useDirection } from "@/lib/ballmac/direction" import { splitPositioner } from "@/lib/ballmac/positioner" import { cn } from "@/lib/utils" /** * Base UI shows the chosen item in the trigger from an `items` map (value to label), because the list is not mounted while it is closed. So that * `<Select><SelectTrigger><SelectValue /></SelectTrigger><SelectContent><SelectItem value="a">Apple</SelectItem>…` keeps working as it does with Radix UI, the * map is read from the SelectItem elements inside the children. Items hidden inside your own components cannot be found: pass `items` yourself then. */ function collectItems(children: React.ReactNode, out: Record<string, React.ReactNode> = {}): Record<string, React.ReactNode> { React.Children.forEach(children, (child) => { if (!React.isValidElement<{ children?: React.ReactNode; value?: unknown }>(child)) return if (child.type === SelectItem && typeof child.props.value === "string") out[child.props.value] = child.props.children else if (child.props.children) collectItems(child.props.children, out) }) return out } type SelectProps = Omit<React.ComponentProps<typeof SelectPrimitive.Root>, "value" | "defaultValue" | "onValueChange" | "multiple"> & { value?: string defaultValue?: string onValueChange?: (value: string) => void /** Reading direction for the arrow keys. Defaults to the page's. */ dir?: "ltr" | "rtl" } function Select({ children, items, dir: dirProp, onValueChange, ...props }: SelectProps) { const dir = useDirection(dirProp) const found = React.useMemo(() => items ?? collectItems(children), [items, children]) return ( <DirectionProvider dir={dir}> <SelectPrimitive.Root data-slot="select" items={found} onValueChange={(v) => onValueChange?.(v == null ? "" : String(v))} {...props}> {children} </SelectPrimitive.Root> </DirectionProvider> ) } function SelectGroup(props: React.ComponentProps<typeof SelectPrimitive.Group>) { return <SelectPrimitive.Group data-slot="select-group" {...props} /> } function SelectValue(props: React.ComponentProps<typeof SelectPrimitive.Value>) { return <SelectPrimitive.Value data-slot="select-value" {...props} /> } type SelectTriggerProps = Omit<React.ComponentProps<typeof SelectPrimitive.Trigger>, "className"> & { className?: string /** Matches Input and Button heights: sm is h-8, default is h-9. */ size?: "sm" | "default" } function SelectTrigger({ className, size = "default", children, ...props }: SelectTriggerProps) { return ( <SelectPrimitive.Trigger data-slot="select-trigger" data-size={size} className={cn( "flex w-fit min-w-0 items-center justify-between gap-2 whitespace-nowrap rounded-md border border-input bg-background px-3 text-sm text-foreground shadow-xs outline-none transition-[color,border-color,box-shadow] duration-150 dark:bg-input/30 dark:hover:bg-input/50", "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20", "disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground", "data-[size=default]:h-[var(--bm-control-h,calc(var(--spacing)*9))] data-[size=sm]:h-[var(--bm-control-h-sm,calc(var(--spacing)*8))] data-[size=sm]:px-2.5 data-[size=sm]:text-[13px]", "*:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground", className )} {...props} > {children} <SelectPrimitive.Icon className="flex"> <ChevronDownIcon className="size-4 opacity-60" aria-hidden="true" /> </SelectPrimitive.Icon> </SelectPrimitive.Trigger> ) } type SelectContentProps = Omit<React.ComponentProps<typeof SelectPrimitive.Popup>, "className"> & Pick<React.ComponentProps<typeof SelectPrimitive.Positioner>, "side" | "alignOffset" | "collisionPadding"> & { className?: string align?: "start" | "center" | "end" /** "popper" opens below the trigger like a menu; "item-aligned" overlaps the trigger like a native select. */ position?: "popper" | "item-aligned" /** Distance in px from the trigger when position is "popper". */ sideOffset?: number } function SelectContent({ className, children, position = "popper", align = "start", sideOffset = 4, ...rest }: SelectContentProps) { const [placement, props] = splitPositioner(rest) return ( <SelectPrimitive.Portal> <SelectPrimitive.Positioner alignItemWithTrigger={position === "item-aligned"} align={align} sideOffset={position === "popper" ? sideOffset : 0} className="z-50 outline-none" {...placement} > <SelectPrimitive.Popup data-slot="select-content" className={cn( "relative flex max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) flex-col overflow-hidden rounded-lg border bg-popover/[var(--bm-material-alpha,100%)] backdrop-blur-[var(--bm-material-blur,0px)] text-popover-foreground shadow-[0_8px_24px_-6px_rgb(0_0_0/0.18),0_2px_6px_-2px_rgb(0_0_0/0.08)]", "transition-[opacity,scale] duration-150 data-starting-style:scale-95 data-starting-style:opacity-0 data-ending-style:scale-95 data-ending-style:opacity-0 motion-reduce:transition-none", position === "popper" && "min-w-(--anchor-width)", className )} {...props} > <SelectScrollUpButton /> <SelectPrimitive.List className="min-h-0 flex-1 overflow-y-auto p-1 outline-none">{children}</SelectPrimitive.List> <SelectScrollDownButton /> </SelectPrimitive.Popup> </SelectPrimitive.Positioner> </SelectPrimitive.Portal> ) } function SelectLabel({ className, ...props }: Omit<React.ComponentProps<typeof SelectPrimitive.GroupLabel>, "className"> & { className?: string }) { return ( <SelectPrimitive.GroupLabel data-slot="select-label" className={cn("px-2 pt-2 pb-1 text-xs font-medium text-muted-foreground", className)} {...props} /> ) } function SelectItem({ className, children, ...props }: Omit<React.ComponentProps<typeof SelectPrimitive.Item>, "className"> & { className?: string }) { return ( <SelectPrimitive.Item data-slot="select-item" className={cn( "relative flex w-full cursor-default select-none items-center gap-2 rounded-md py-1.5 pe-8 ps-2 text-sm outline-hidden", "data-highlighted:bg-accent data-highlighted:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground", "*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className )} {...props} > <span data-slot="select-item-indicator" className="absolute end-2 flex size-3.5 items-center justify-center"> <SelectPrimitive.ItemIndicator> <CheckIcon className="size-4 text-foreground" aria-hidden="true" /> </SelectPrimitive.ItemIndicator> </span> <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText> </SelectPrimitive.Item> ) } function SelectSeparator({ className, ...props }: Omit<React.ComponentProps<typeof SelectPrimitive.Separator>, "className"> & { className?: string }) { return ( <SelectPrimitive.Separator data-slot="select-separator" className={cn("pointer-events-none -mx-1 my-1 h-px bg-border", className)} {...props} /> ) } function SelectScrollUpButton({ className, ...props }: Omit<React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>, "className"> & { className?: string }) { return ( <SelectPrimitive.ScrollUpArrow data-slot="select-scroll-up-button" className={cn("flex cursor-default items-center justify-center py-1 text-muted-foreground", className)} {...props} > <ChevronUpIcon className="size-4" aria-hidden="true" /> </SelectPrimitive.ScrollUpArrow> ) } function SelectScrollDownButton({ className, ...props }: Omit<React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>, "className"> & { className?: string }) { return ( <SelectPrimitive.ScrollDownArrow data-slot="select-scroll-down-button" className={cn("flex cursor-default items-center justify-center py-1 text-muted-foreground", className)} {...props} > <ChevronDownIcon className="size-4" aria-hidden="true" /> </SelectPrimitive.ScrollDownArrow> ) } export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, type SelectContentProps, type SelectProps, type SelectTriggerProps, }Update the import paths to match your project setup.
Usage
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from "@/components/ballmac/select"The full example is in the Code tab above.
Examples
Grouped
import { Globe } from "lucide-react"
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectSeparator,
SelectTrigger,
SelectValue,
} from "@/components/ballmac/select"
const regions = [
{ label: "North America", items: [["us-east", "US East (Virginia)"], ["us-west", "US West (Oregon)"], ["ca-central", "Canada (Montreal)"]] },
{ label: "Europe", items: [["eu-west", "Ireland"], ["eu-central", "Frankfurt"], ["eu-north", "Stockholm"]] },
{ label: "Asia Pacific", items: [["ap-south", "Mumbai"], ["ap-southeast", "Singapore"], ["ap-northeast", "Tokyo"]] },
] as const
export default function SelectGrouped() {
return (
<Select>
<SelectTrigger className="w-full max-w-64" aria-label="Deployment region">
<Globe />
<SelectValue placeholder="Deployment region" />
</SelectTrigger>
<SelectContent>
{regions.map((region, i) => (
<SelectGroup key={region.label}>
{i > 0 ? <SelectSeparator /> : null}
<SelectLabel>{region.label}</SelectLabel>
{region.items.map(([value, label]) => (
<SelectItem key={value} value={value}>
{label}
</SelectItem>
))}
</SelectGroup>
))}
</SelectContent>
</Select>
)
}API reference
<SelectTrigger>
| Prop | Type | Default |
|---|---|---|
sizeMatches Input and Button heights: sm is h-8, default is h-9. | "sm" | "default" | "default" |
<SelectContent>
| Prop | Type | Default |
|---|---|---|
position"popper" opens below the trigger like a menu; "item-aligned" overlaps the trigger like a native select. | "popper" | "item-aligned" | "popper" |
sideOffsetDistance in px from the trigger when position is "popper". | number | 4 |
Also accepts the standard attributes of its root element.
Accessibility
| Key | Action |
|---|---|
| Space / Enter / ArrowDown | Opens the menu |
| ArrowUp / ArrowDown | Moves between items |
| Enter | Selects the focused item |
| Type a letter | Jumps to the matching item |
| Escape | Closes the menu |
Quality scorecard
Every applicable check passes
Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.2, across 2 examples.
Passed: Accessibility scan
No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).
Passed: Small screens
No sideways scrolling at 360, 390 or 1280 px wide.
Passed: Reduced motion
No endless animation to begin with.
Passed: Right to left
Mirrors correctly in Arabic, Hebrew, Persian and Urdu layouts (0% of elements off the mirror, limit 15%).
Passed: Clean console
No console errors or React hydration errors while loading.
Passed: Keyboard
2 tab stops, each showing a visible change when it takes focus. 5 documented keys.
Not applicable: Loading, empty and error
Does not show data or take submissions.
Passed: Automated tests
Covered by select.test.tsx.
For information: Footprint
2.1 KB of source (gzip) in 1 file. Installs radix-ui, lucide-react.
Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.
Use with AI
Pick one value from a list. Compose Select > SelectTrigger > SelectValue and SelectContent > SelectItem (group with SelectGroup + SelectLabel). The menu is portalled and keyboard navigable with typeahead. With the shadcn MCP server set up (guide), ask your agent:
Add the Ballmac UI Select (@ballmac/select) to this project with the shadcn MCP, then use it where it fits.
Use it for
- Choosing one option from 4 to 20 fixed values (timezone, role, region)
- Compact filters in toolbars (size sm)
- Grouped options such as regions by continent
Not for
- Two or three options that should stay visible (use a radio group or segmented control)
- Long searchable lists (use a combobox)
- Actions rather than values (use a dropdown menu)
Registry JSON: https://ui.ballmac.com/r/select.json
Credits
Based on shadcn/ui Select, adapted by Ballmac. Free to use in personal and commercial projects.
- Registry
- @ballmac/directionshadcn/utils
Pairs well with
Label
An accessible form label built on Radix Label that dims itself when the paired peer control is disabled and never selects text on double-click.
Button
A button with six variants, three sizes, a pill shape and a built-in loading state. buttonVariants() styles links the same way.
Dialog
A Radix modal dialog with a blurred overlay, centered card surface that fits 360 px screens, header and footer parts, optional close button and animations.
Accordion
Vertically stacked disclosure sections on Radix Accordion, single or multiple open, with hairline dividers, a rotating plus and height animation.
Ballmac UI Pro
Need the whole screen, not one piece?
311 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.
Not ready? Try three Pro blocks free
Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.