Skip to main content

Starwind UI v3.0 is now available! Migration guide

Native Select

Info

For a styled select component, see the Select component.

Installation

Usage

---
import { NativeSelect, NativeSelectOption } from "@/components/starwind/native-select";
---
<NativeSelect class="w-[240px]">
<NativeSelectOption value="" disabled>Select a fruit</NativeSelectOption>
<NativeSelectOption value="apple">Apple</NativeSelectOption>
<NativeSelectOption value="banana">Banana</NativeSelectOption>
<NativeSelectOption value="blueberry">Blueberry</NativeSelectOption>
<NativeSelectOption value="pineapple">Pineapple</NativeSelectOption>
</NativeSelect>

Composition

Place options directly inside NativeSelect, or organize them with NativeSelectOptGroup:

NativeSelect
├── NativeSelectOption
└── NativeSelectOptGroup
├── NativeSelectOption
└── NativeSelectOption

Groups

Use NativeSelectOptGroup to organize options into categories.

Disabled

Add the disabled prop to disable the entire select, or disable specific options.

Invalid

Use aria-invalid for assistive technology and data-error-visible to opt into the visible error state after validation has run.

Please select a framework.

Size

Use the size prop to render compact or larger controls.

Native Select vs Select

Use Native Select for simple forms when you want browser-native behavior and mobile pickers. Use Select when you need custom popover behavior, search, and advanced interaction patterns.

Tip

Prefer NativeSelect for straightforward form controls and mobile-first flows where native platform pickers are beneficial. Choose Select when you need richer UI features like searchable options, custom popover positioning, and advanced interactions.

RTL

Set dir="rtl" to support right-to-left languages.

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Native Select

Inherits select attributes. Omits `size`.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Changelog

View version history v1.1.1 4 releases

v1.1.1

  • Named the generated aggregate default export so React and Astro tooling can identify the installed component cleanly.

v1.1.0

  • Added contract-generated Astro and React implementations while preserving the component’s existing public API and styling.
  • Native Select follows Astro and HTML option-selection semantics. Omitting a value selects the first option naturally; the legacy React-style defaultValue prop is no longer used.

v1.0.1

  • Refactor tailwind variants functions into separate variants.ts file

v1.0.0

  • Initial release with starwind v1.16.0