For a styled select component, see the Select component.
Installation
- CLI
- Manual
Usage
showLineNumbers
showLineNumbers
Examples
With Groups
Organize options usingNativeSelect.OptGroup for better categorization.
showLineNumbers
Disabled State
Disable individual options or the entire select component.Invalid State
Show validation errors with thearia-invalid attribute and error styling.
showLineNumbers
Native Select vs Select
- Use
NativeSelectwhen you need native browser behavior, better performance, or mobile-optimized dropdowns. - Use
Selectwhen you need custom styling, animations, or complex interactions.
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-labeloraria-labelledbyfor additional context when needed.
showLineNumbers
API Reference
NativeSelect.Root
The main select component that wraps the native HTML select element.| Prop | Type | Default |
|---|---|---|
class | string |
<select> element.
NativeSelect.Option
Represents an individual option within the select.| Prop | Type | Default |
|---|---|---|
value | string | |
disabled | boolean | false |
class | string |
<option> element.
NativeSelect.OptGroup
Groups related options together for better organization.| Prop | Type | Default |
|---|---|---|
label | string | |
disabled | boolean | false |
class | string |
<optgroup> element.