NativeSelect
A styled native HTML select element with consistent design system integration.
Demo
Dependencies
lucide-reactclsxtailwind-merge
Props
This is a base primitive. It accepts standard HTML attributes plus className for styling via cn().
Source
import { cn } from "@/lib/utils";
import { ChevronDown } from "lucide-react";
export interface NativeSelectProps extends React.SelectHTMLAttributes<HTMLSelectElement> {
options: { value: string; label: string }[];
placeholder?: string;
}
export function NativeSelect({
options,
placeholder,
className,
...props
}: NativeSelectProps) {
return (
<div className="relative">
<select
className={cn(
"flex h-10 w-full appearance-none rounded-md border border-gray-200 bg-white px-3 py-2 pr-8 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-gray-400 disabled:cursor-not-allowed disabled:opacity-50",
className,
)}
{...props}
>
{placeholder && (
<option value="" disabled>
{placeholder}
</option>
)}
{options.map((opt) => (
<option key={opt.value} value={opt.value}>
{opt.label}
</option>
))}
</select>
<ChevronDown className="pointer-events-none absolute right-2 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400" />
</div>
);
}
CLI
npx genui add native-select