Native Select
Native Select components are used to display a list of items in a compact menu, leveraging the browser's native capabilities for better mobile experience and accessibility.
Installation
Install the component using the Tailgrids CLI.
npx @tailgrids/cli add native-selectAnatomy
Import the component and pass the required props.
import {
NativeSelect,
NativeSelectOption
} from "@/registry/core/native-select";
export const NativeSelectExample = () => (
<NativeSelect>
<NativeSelectOption value="option1">Option 1</NativeSelectOption>
<NativeSelectOption value="option2">Option 2</NativeSelectOption>
</NativeSelect>
);Examples
States
The Native Select component supports error and success states for validation feedback.
Success message
Error message
Placeholder
Use the placeholder prop to display a placeholder when no value is selected.
Disabled
The component can be disabled to prevent user interaction.
Option Groups
Use NativeSelectOptGroup to group related options together.
API Reference
NativeSelect
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'default', 'success', 'error' | 'default' | Controls the visual state of the select |
placeholder | string | - | Sets a placeholder for the select |
disabled | boolean | - | Disables the select |
className | string | - | Additional CSS classes to apply to the wrapper |
NativeSelectOption
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
NativeSelectOptGroup
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |