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 playgroundAbout
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
npm i @ashutoshswamy/smouiUsage
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
More navigation components
- BreadcrumbsA trail that folds its middle into an ellipsis. Press it and the hidden crumbs spring out in order.
- DockIcons swell around the cursor and settle back on a spring.
- FlyoutNavOne panel that follows you. Move between items and it glides sideways and resizes to the new content while the content cross-fades.
- GooMenuA plus that throws its items out as liquid bubbles and fuses them back on close.
- MorphTooltipOne tooltip for the whole toolbar. It stretches to the next tool and resizes to its label.
- PaginationOne accent pill slides to the page you pick. Long lists fold into ellipses that follow the current page.