npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@surstromming/dropdown-menu

v0.1.7

Published

A menu of actions anchored to a trigger.

Readme

@surstromming/dropdown-menu

A menu of actions anchored to a trigger — a row's "⋯", a user menu. Data-driven: pass an array, wire a trigger, listen for select. Built on the Popover shell (outside-click + Escape dismissal).

Dependency graph

graph LR
  dropdown_menu["@surstromming/dropdown-menu"]
  design["@surstromming/design"]
  icon["@surstromming/icon"]
  popover["@surstromming/popover"]
  scroll_area["@surstromming/scroll-area"]
  util["@surstromming/util"]
  dropdown_menu --> design
  dropdown_menu --> icon
  dropdown_menu --> popover
  popover --> design
  popover --> scroll_area
  popover --> util
  scroll_area --> design
  scroll_area --> util

Usage

<template>
  <DropdownMenu :items="items" @select="run">
    <template #trigger="{ toggle }">
      <Button variant="outline" @click="toggle">Options</Button>
    </template>
  </DropdownMenu>
</template>

<script setup lang="ts">
import { DropdownMenu, type DropdownMenuItem } from '@surstromming/dropdown-menu'
import { Button } from '@surstromming/button'
import { Pencil, Trash } from 'lucide'

const items: DropdownMenuItem[] = [
  { label: 'Edit', value: 'edit', icon: Pencil },
  { separator: true },
  { label: 'Delete', value: 'delete', icon: Trash, destructive: true },
]

const run = (value: string) => { /* value is 'edit' | 'delete' */ }
</script>

Props

| Prop | Type | Default | Notes | | -------------- | -------------------- | ------------ | ---------------------------------------- | | items | DropdownMenuItem[] | — (required) | Options, submenus and separators, in order | | align | start \| end | start | Which trigger edge the menu lines up with | | side | top \| right \| bottom \| left | bottom | Which trigger edge the menu opens from | | layer | popover \| menu \| modal | popover | From Popover — menu clears a teleported sidebar drawer | | v-model:open | boolean | false | Optional — the trigger toggles it |

type DropdownMenuItem =
  | { label: string; value: string; icon?: IconNode; disabled?: boolean; destructive?: boolean }
  | { label: string; items: DropdownMenuItem[]; icon?: IconNode; disabled?: boolean }
  | { separator: true }

The middle shape is a submenu — a row that opens a menu of its own beside it. It has items where an option has value, and that is the whole difference: only a leaf can be chosen, so a row that could be selected and opened would be one row meaning two things. items is the item type again, so a submenu holds separators, and further submenus.

const items: DropdownMenuItem[] = [
  { label: 'Edit', value: 'edit', icon: Pencil },
  {
    label: 'Share',
    icon: Share2,
    items: [
      { label: 'Copy link', value: 'share-link' },
      { separator: true },
      { label: 'Email', value: 'share-email' },
    ],
  },
]

select fires with the leaf's value however deep it was, and the whole menu closes.

| Emit | Payload | When | | -------- | ------- | ----------------------------- | | select | value | An item is chosen (menu closes) |

Slots

| Slot | Props | Description | | --------- | ---------------- | --------------------------------------------- | | trigger | { open, toggle } | The anchor. Call toggle to open/close. |

The trigger is yours so it can be any control; add aria-haspopup="menu" and :aria-expanded="open" to it for the full a11y contract.

Anatomy

Popover
  ├─ <slot name="trigger" />
  └─ MenuPanel → div.menu[role=menu]
       ├─ button.item[role=menuitem]                     // icon + label; .isDestructive
       ├─ div.separator[role=separator]
       └─ Popover                                        // a submenu
            ├─ button.item[aria-haspopup=menu] + svg.caret
            └─ MenuPanel → div.menu[role=menu]           // … and so on down

MenuPanel is private and recursive: a submenu is another Popover, on side="right" align="start", holding another panel. Reusing the shell is what keeps the second surface identical to the first — same border, same shadow, same teleport out of whatever is scrolling — and it is why nothing here has a depth limit.

Keyboard

| Key | Action | | ------------- | --------------------------------------------------- | | ↓ / ↑ | Move within the panel (wraps, skips separators/disabled) | | → | Open the focused submenu and step into it | | ← | Close this submenu, back to the row that opened it | | Home / End| First / last item of the panel | | Enter / Space | Fire the focused item (native button) | | Escape | Close the menu (from Popover) | | Tab | Close and move on — a menu isn't a tab stop | | outside click | Close (from Popover) |

Escape closes the whole menu rather than one level at a time: Popover claims the key in the capture phase and the outermost one registered first, so it answers first. ← is the step-back-one key.

A submenu also opens on hover, and stays open for a moment after the pointer leaves the row that opened it. The panel is off to the right, so reaching it means crossing the rows underneath — and closing on the first of those is what makes a flyout feel like it is running away.

Opening moves focus to the first item; closing returns focus to the trigger, so a keyboard user never loses their place. A submenu opened by pointer leaves focus where it is — it was a hover, not a request to go there; → is what steps into one.

Tokens

Panel from Popover (popover, shadow(md)). Items: accent highlight shared by hover and focus; destructive items recolour text/icon and use a destructive @ 10% highlight; separators are a border hairline.

Notes

Actions only — no checkbox or radio items. For a value you keep (a chosen option), that's Select, not a menu.

A submenu row is not selectable. Nothing stops a consumer nesting six deep, but a menu that needs it is usually a dialog.