Skip to main content

Starwind UI v3.0 beta is now available! Read the migration guide

Native Select

Runtime example adjustment

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.

Info

For a styled select component, see the Select component.

Installation

Framework Availability

Astro Available React Available

Native Select is available for Astro and React.

Usage

Groups

Use NativeSelectOptGroup to organize options into categories.

Runtime example adjustment

The grouped example now relies on the first native option for its initial selection instead of passing the legacy defaultValue prop.

Disabled

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

Runtime example adjustment

Set an initial native selection with selected on NativeSelectOption. This replaces the React-style defaultValue previously passed to NativeSelect.

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.

Runtime example adjustment

The example now uses native option-selection semantics. Visible validation styling follows the shared data-error-visible contract; keep aria-invalid as well so the invalid state remains available to assistive technology.

Size

Use the size prop to render compact or larger controls.

Runtime example adjustment

Each size example now lets its first native option provide the initial selection rather than using the legacy defaultValue prop.

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.

Runtime example adjustment

The RTL example now uses native option-selection semantics and no longer passes the legacy defaultValue prop.

API Reference

Styled Component API

These props are added or materially changed by the installed Astro styled component. Standard HTML attributes remain available through the inherited interfaces noted below. 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

v1.1.0

  • Added contract-generated Astro and React implementations while preserving the component’s existing public API and styling.

v1.0.1

  • Refactor tailwind variants functions into separate variants.ts file

v1.0.0

  • Initial release with starwind v1.16.0