Dropdown

A menu with one highlight that stretches between rows. Arrow keys, Home and End move it, Enter picks, Escape closes. Overlays.

Open playground

About

Dropdown is a React component in the Overlays category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { Dropdown } from "@ashutoshswamy/smoui" and set items, onSelect, align.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { Dropdown } from "@ashutoshswamy/smoui";

<Dropdown
  trigger="Actions"
  onSelect={(id) => run(id)}
  items={[{ id: "edit", label: "Rename", icon: "document" }, { id: "del", label: "Delete", danger: true, separator: true }]}
/>

Props 3

items

Rows. Icons are Heroicon names.

{ id; label; icon?; shortcut?; danger?; separator?; disabled? }[]
onSelect

Called with the picked item id.

(id: string) => void
align

Which edge of the button it lines up with.

"start""center""end"default "start"