Components
Loading preview...
Enhanced shadcn/ui select
npx shadcn@latest add https://21st.dev/r/originui/selectimport { Label } from "@/components/ui/label";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { useId } from "react";
function StatusDot({ className }: { className?: string }) {
return (
<svg
width="8"
height="8"
fill="currentColor"
viewBox="0 0 8 8"
xmlns="http://www.w3.org/2000/svg"
className={className}
aria-hidden="true"
>
<circle cx="4" cy="4" r="4" />
</svg>
);
}
function Component() {
const id = useId();
return (
<div className="space-y-2 min-w-[300px]">
<Label htmlFor={id}>Status select</Label>
<Select defaultValue="1">
<SelectTrigger
id={id}
className="[&>span]:flex [&>span]:items-center [&>span]:gap-2 [&>span_svg]:shrink-0"
>
<SelectValue placeholder="Select status" />
</SelectTrigger>
<SelectContent className="[&_*[role=option]>span>svg]:shrink-0 [&_*[role=option]>span>svg]:text-muted-foreground/80 [&_*[role=option]>span]:end-2 [&_*[role=option]>span]:start-auto [&_*[role=option]>span]:flex [&_*[role=option]>span]:items-center [&_*[role=option]>span]:gap-2 [&_*[role=option]]:pe-8 [&_*[role=option]]:ps-2">
<SelectItem value="1">
<span className="flex items-center gap-2">
<StatusDot className="text-emerald-600" />
<span className="truncate">Completed</span>
</span>
</SelectItem>
<SelectItem value="2">
<span className="flex items-center gap-2">
<StatusDot className="text-blue-500" />
<span className="truncate">In Progress</span>
</span>
</SelectItem>
<SelectItem value="3">
<span className="flex items-center gap-2">
<StatusDot className="text-amber-500" />
<span className="truncate">Pending</span>
</span>
</SelectItem>
<SelectItem value="4">
<span className="flex items-center gap-2">
<StatusDot className="text-gray-500" />
<span className="truncate">Cancelled</span>
</span>
</SelectItem>
<SelectItem value="5">
<span className="flex items-center gap-2">
<StatusDot className="text-red-500" />
<span className="truncate">Failed</span>
</span>
</SelectItem>
</SelectContent>
</Select>
</div>
);
}
export { Component };