Skip to main content

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

Runtime example adjustment

Runtime dropdown items model menu actions. Use Navigation Menu for site links instead of rendering anchors through DropdownItem.

Installation

Framework Availability

Astro Available React Available

Dropdown is available for Astro and React.

Usage

Action Menu

A common use case is a compact list of application actions. Each DropdownItem participates in the Runtime menu’s keyboard navigation and selection behavior.

Runtime example adjustment

The old anchor-polymorphism example is now an action menu because Runtime dropdown items expose menu-item behavior rather than a styled anchor API.

Hover Open

The dropdown can be configured to open on hover in addition to click.

Runtime example adjustment

Hover opening is handled by the Runtime menu controller; its items remain menu actions and no longer use the legacy as="a" API.

Use DropdownSub, DropdownSubTrigger, and DropdownSubContent to nest secondary actions.

Shortcuts

Add DropdownShortcut to display keyboard hints alongside actions.

Placement Options

You can position the dropdown menu in different ways by customizing the side and align properties.

With Icons

You can add icons to dropdown items for better visual cues.

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.

Dropdown Item

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
inset boolean false
Description
Adds leading inset spacing for visual alignment.
Classification
Wrapper prop

Dropdown Checkbox Item

Inherits div attributes. Omits `aria-checked` and `role`.

Contains the following additional props:

Prop Type Default Toggle details
closeOnClick boolean false
Description
Closes the containing surface after the item is activated.
Classification
Wrapper prop
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
Wrapper prop
showIndicator boolean true
Description
Shows the generated selection indicator.
Classification
Wrapper prop

Dropdown Radio Item

Inherits div attributes. Omits `aria-checked` and `role`.

Contains the following additional props:

Prop Type Default Toggle details
closeOnClick boolean false
Description
Closes the containing surface after the item is activated.
Classification
Wrapper prop
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
Wrapper prop
showIndicator boolean true
Description
Shows the generated selection indicator.
Classification
Wrapper prop
value Required string
Description
Controls or identifies the component value.
Classification
Wrapper prop

Dropdown Label

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
inset boolean false
Description
Adds leading inset spacing for visual alignment.
Classification
Wrapper prop

Dropdown Sub Trigger

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
inset boolean false
Description
Adds leading inset spacing for visual alignment.
Classification
Wrapper prop

Dropdown Sub Content

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
side "top" | "right" | "bottom" | "left" "right"
Description
Selects the preferred side for floating content.
Classification
Primitive override
Primitive prop
menu.Popup.side
sideOffset number 0
Description
Sets the distance in pixels between floating content and its anchor.
Classification
Primitive override
Primitive prop
menu.Popup.sideOffset

Primitive And Runtime API

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

Primitive API

Runtime API

Menu primitive
createMenu from @starwind-ui/runtime/menu

Changelog

v3.0.0

  • Rebuilt Dropdown on Starwind Runtime while preserving its styled API over the shared Menu behavior.
  • See the Menu Primitive for the underlying unstyled anatomy and behavior API.