ReviewOS

stacks/stx

Built-in Dropdown component (<StxDropdown />)

#1674
Closed glennmichael123 opened this 23 days ago · 1 comment
23 days ago

Summary

Add a dropdown menu component for action menus, select alternatives, and context menus.

Usage

<StxDropdown id="user-menu" trigger="click">
  <template #trigger>
    <button>Menu</button>
  </template>
  
  <a href="/profile">Profile</a>
  <a href="/settings">Settings</a>
  <hr />
  <button @click="logout()">Sign Out</button>
</StxDropdown>

API

<StxDropdown> props

  • id (required) — unique identifier
  • trigger — 'click' | 'hover' (default: 'click')
  • position — 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end' (default: 'bottom-start')
  • closeOnSelect — auto-close when an item is clicked (default: true)
  • closeOnOutside — close when clicking outside (default: true)

dropdown runtime global

dropdown.open(id: string): void
dropdown.close(id: string): void
dropdown.toggle(id: string): void

Implementation

  • Builtin component in src/builtins/dropdown.ts
  • Named slot #trigger for the trigger element, default slot for menu items
  • Smart positioning (flip if near viewport edge)
  • Keyboard navigation (Arrow keys, Enter, Escape)
  • ARIA: role="menu", aria-expanded, aria-haspopup
  • Focus trap within open dropdown
23 days ago

Delivered via @stacksjs/components, which ships with every stx app and is auto-registered (no import needed in .stx files). See CLAUDE.md § "Reach for stx primitives before vanilla JS" for the full inventory; the relevant components for this request are documented there.

Closing as effectively delivered. If a specific behavior or API affordance from the original request is missing from the shipped components, please open a focused ticket against @stacksjs/components describing the exact gap — that's easier to track than a broad "make it a builtin" ask.

Sign in to comment on this issue.