Skip to main content

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

Runtime example adjustment

Form props such as name, required, readOnly, and defaultValue belong on Select. The trigger now focuses on presentation and uses its placeholder prop for the installed value part.

Installation

Framework Availability

Astro Available React Available

Select is available for Astro and React.

Usage

Form participation

Select serializes its value through a hidden input and follows native form reset behavior.

<form>
<Select name="role" required>
<SelectTrigger placeholder="Choose a role" />
<SelectContent>
<SelectItem value="admin">Administrator</SelectItem>
<SelectItem value="member">Member</SelectItem>
</SelectContent>
</Select>
<button type="submit">Save</button>
</form>

Programmatic value changes

Dispatch starwind:set-value on the Select root. Listen for the root-scoped starwind:value-change event when the selected value changes.

Runtime example adjustment

The legacy document-wide selection event has been replaced by the root-targeted starwind:set-value command, preventing unrelated Select instances from doing extra work.

For a searchable text input with listbox suggestions, install Combobox instead of adding the removed search part.

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.

Select

Inherits div attributes. Omits `defaultValue` and `onChange`.

Contains the following additional props:

Prop Type Default Toggle details
defaultOpen boolean false
Description
Sets the initial open state when the component is uncontrolled.
Classification
Primitive override
Primitive prop
select.Root.defaultOpen
disabled boolean false
Description
Disables interaction with the component.
Classification
Primitive override
Primitive prop
select.Root.disabled
required boolean false
Description
Marks the control as required for form validation.
Classification
Primitive override
Primitive prop
select.Root.required

Select Trigger

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
asChild boolean false
Description
Merges the component behavior and props into its child element.
Classification
Primitive override
Primitive prop
select.Trigger.asChild
iconClass string
Description
Adds classes to the component's generated icon.
Classification
Wrapper prop
placeholder string
Description
Provides fallback text for the value element generated inside the trigger.
Classification
Wrapper prop
showIcon boolean true
Description
Shows the component's generated icon.
Classification
Wrapper prop
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant
valueClass string
Description
Adds classes to the generated value element.
Classification
Wrapper prop

Select Value

Inherits span attributes.

Contains the following additional props:

Prop Type Default Toggle details
placeholder string
Description
Provides fallback text when no value is available.
Classification
Wrapper prop

Select Content

Inherits div attributes.

Contains the following additional props:

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

Select Item

Inherits div attributes. Omits `role`.

Contains the following additional props:

Prop Type Default Toggle details
disabled boolean false
Description
Disables interaction with the component.
Classification
Styled variant
Primitive prop
select.Item.disabled
indicatorClass string
Description
Adds classes to the generated selection indicator.
Classification
Wrapper prop
inset boolean false
Description
Adds leading inset spacing for visual alignment.
Classification
Styled variant
showIndicator boolean true
Description
Shows the generated selection indicator.
Classification
Wrapper prop
value Required string
Description
Controls or identifies the component value.
Classification
Primitive override
Primitive prop
select.Item.value

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Select.

Primitive API

Runtime API

Select primitive
createSelect from @starwind-ui/runtime/select

Changelog

v2.0.0

  • Rebuilt Select on Starwind Runtime for selection, forms, events, and scroll behavior; search is now provided by Combobox.
  • See the Select Primitive for the underlying unstyled anatomy and behavior API.