--- title: Native Select description: A styled native HTML select element with consistent design system integration. component: true --- import { InfoIcon } from "lucide-react" }> For a styled select component, see the [Select](/docs/components/select) component. ## Installation CLI Manual ```bash npx shadcn@latest add native-select ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx showLineNumbers import { NativeSelect, NativeSelectOptGroup, NativeSelectOption, } from "@/components/ui/native-select" ``` ```tsx showLineNumbers Select a fruit Apple Banana Blueberry Grapes Pineapple ``` ## Examples ### With Groups Organize options using `NativeSelectOptGroup` for better categorization. ```tsx showLineNumbers Select a food Apple Banana Blueberry Carrot Broccoli Spinach ``` ### Disabled State Disable individual options or the entire select component. ### Invalid State Show validation errors with the `aria-invalid` attribute and error styling. ```tsx showLineNumbers Select a country United States United Kingdom Canada ``` ### Form Integration Use with form libraries like React Hook Form for controlled components. ### Input Group Integration Combine with `InputGroup` for complex input layouts. ## Native Select vs Select - Use `NativeSelect` when you need native browser behavior, better performance, or mobile-optimized dropdowns. - Use `Select` when you need custom styling, animations, or complex interactions. The `NativeSelect` component provides native HTML select functionality with consistent styling that matches your design system. ## Accessibility - The component maintains all native HTML select accessibility features. - Screen readers can navigate through options using arrow keys. - The chevron icon is marked as `aria-hidden="true"` to avoid duplication. - Use `aria-label` or `aria-labelledby` for additional context when needed. ```tsx showLineNumbers English Spanish French ``` ## API Reference ### NativeSelect The main select component that wraps the native HTML select element. | Prop | Type | Default | | ----------- | -------- | ------- | | `className` | `string` | | All other props are passed through to the underlying `