SpringMenu

A menu that unrolls from its trigger on a spring. Items cascade in, one highlight stretches between them, and icons, shortcuts, groups and a red danger item are built in. Arrows, Home, End and typing a letter all move through it. Navigation.

Open playground

About

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

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

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

<SpringMenu
  trigger="Options"
  items={[
    { label: "Rename", hint: "R", onSelect: rename },
    { label: "Delete", danger: true, separatorBefore: true, onSelect: remove },
  ]}
/>

Props 5

trigger

Trigger button content.

ReactNode
items

Menu entries. `danger` turns one red, `separatorBefore` starts a new group, `hint` is a quiet shortcut.

{ label; icon?; hint?; danger?; disabled?; separatorBefore?; onSelect? }[]
align

Which edge of the trigger the menu lines up with.

"start""end"default "start"
triggerClassName

Class on the trigger.

string
menuClassName

Class on the menu surface.

string