Select
A wrapper for Base UI Select with flexible item types, grouped items, backdrop, custom value rendering, and multiple selection.
—Installation
npx shadcn@latest add @glrk-ui/selectIf you haven't set up the prerequisites yet, check out registry setup.
Usage
Basic
import { SelectWrapper } from "@/components/ui/select"
<SelectWrapper
items={["Apple", "Banana", "Orange"]}
placeholder="Select a fruit"
/>Items format
items accepts primitives, item objects, groups, and separators — mixed freely:
const items = [
"Simple string",
42,
true,
"---", // separator
{ label: "Custom label", value: "custom" },
{ label: <><SunIcon /> Light</>, value: "light" }, // ReactNode label
{ label: "Disabled", value: "off", disabled: true },
{
group: "Category",
items: ["Option A", "Option B"],
},
]
<SelectWrapper items={items} placeholder="Pick one" />Grouped items
<SelectWrapper
items={[
{ group: "Fruits", items: ["Apple", "Banana"] },
{ group: "Veggies", items: ["Carrot", "Broccoli"] },
]}
placeholder="Select food"
/>Indicator placement
<SelectWrapper items={items} indicatorAt="left" placeholder="Left check" />
<SelectWrapper items={items} indicatorAt="right" placeholder="Right check" /> {/* default */}
<SelectWrapper items={items} indicatorAt="" placeholder="No indicator" />Disabled item
Pass disabled: true on any item object:
<SelectWrapper
items={[
{ label: "Available", value: "a" },
{ label: "Unavailable", value: "b", disabled: true },
]}
placeholder="Select"
/>Backdrop
Renders a fixed backdrop behind the dropdown — useful for modal-style behaviour:
<SelectWrapper items={items} backdrop placeholder="Select with backdrop" />Controlled
const [value, setValue] = useState("apple")
<SelectWrapper
items={["apple", "banana", "orange"]}
value={value}
onValueChange={setValue}
/>With defaultValue (uncontrolled):
<SelectWrapper items={items} defaultValue="banana" />Custom value rendering
Use renderValue to customise what appears in the trigger after selection. Receives the raw value string and the matched item object:
<SelectWrapper
items={[
{ label: <><SunIcon /> Light</>, value: "light" },
{ label: <><MoonIcon /> Dark</>, value: "dark" },
]}
placeholder="Theme"
renderValue={(value, option) => (
<span className="flex items-center gap-1.5">
{value === "light" ? <SunIcon className="size-4" /> : <MoonIcon className="size-4" />}
{value}
</span>
)}
/>
SelectWrapperautomatically mirrors item labels (including ReactNode) into the trigger viaSelectValue.renderValueis only needed when you want a different representation in the trigger than in the list.
Custom styling
<SelectWrapper
items={items}
placeholder="Styled"
triggerCls="w-64 bg-muted"
contentCls="min-w-64"
groupLabelCls="text-primary font-semibold"
groupCls="py-1"
itemCls="rounded-none"
/>Reference
Prop
Type