component
DropdownMenu
A button that opens a short list of actions: MenuItems on Popover's grey plate, with a thin line between groups. The arrow keys move through them, Esc closes it.
Install
npx github:Runceanu/rost add dropdown-menu It lands in src/rost/dropdown-menu/, with what it needs and its contract. Install has the rest.
When to use
A row's actions
A kebab IconButton at the end of a table row, or a More button on a card, with three to seven actions behind it.
When not to use
One or two actions
Show them as Buttons. A menu hides them for no gain.
Picking a value
That's a Select.
Behaviour
Pressing the trigger opens it under the trigger with the focus on the first item. Up and Down move through the items, Home and End to the ends, Enter or Space does the action and closes it. Esc, Tab or a click outside closes it, and the focus goes back to the trigger. It doesn't wrap: Down on the last item stays there.
Accessibility
- Element
role="menu"on the plate,role="menuitem"on each item,role="separator"between groups. The trigger hasaria-haspopup="menu"andaria-expanded. - Name
The trigger's words, or
label. - Keyboard
The arrow keys inside, one Tab stop: the menu isn't in the page's tab order.
- Colour
The edge is drawing; the items carry their own contrast.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
trigger | slot | | |
label | string | | |
children | slot | | |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
margin0pxspacing/gap/none -
margin-block-start8pxspacing/gap/small -
min-width180pxno token yet -
padding4pxspacing/gap/2xsmall -
border-radius12pxspacing/radius/medium -
background#171717dropdown-menu/background -
outline-width1pxspacing/outline/small -
outline-offsetcalc(-1 * var(--spacing-outline-small))on purpose: Composed from a token: the edge sits inside the plate. -
outline-color#3a3a3adropdown-menu/edge -
box-shadow0px 16px 24px 0px rgba(0, 0, 0, 0.16)shadow/floating
insetauto · position-areablock-end span-inline-end · position-try-fallbacksflip-block, flip-inline · flex-directioncolumn · bordernone · outline-stylesolid · colorinherit
separator
-
height1pxspacing/outline/small -
margin-top4pxspacing/gap/2xsmall -
margin-bottom4pxspacing/gap/2xsmall -
background#3a3a3adropdown-menu/separator
displayblock
Part of DropdownMenu
ContextMenu
DropdownMenu's plate, opened where you right-click instead of under a button. For the actions on a row or a card, as a shortcut.
Install
npx github:Runceanu/rost add context-menu It lands in src/rost/context-menu/, with what it needs and its contract. Install has the rest.
When to use
A shortcut to a row's actions
Right-clicking an invoice in a list for Duplicate or Delete, when the same actions are also somewhere you can see.
When not to use
The only way to do something
Nobody knows to right-click, and phones can't. Put the actions in a DropdownMenu on the row too.
Behaviour
A right-click on the area opens the menu where the pointer is, moved in if it would go off the window, with the focus on the first item. The context menu key and Shift+F10 open it at the focused element. Inside it works as DropdownMenu does: Up and Down, Home and End, Enter to act, Esc, Tab or a click outside to close, and the focus goes back to where it was.
Accessibility
- Element
role="menu"on the plate,role="menuitem"on each item. - Name
label. - Keyboard
The context menu key or Shift+F10 on anything focusable inside the area opens it.
- Colour
DropdownMenu's: the edge is drawing; the items carry their own contrast.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
children | slot | | |
items | slot | | |
label | string | | |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
displaycontents
menu
-
margin0pxspacing/gap/none -
min-width180pxno token yet -
padding4pxspacing/gap/2xsmall -
border-radius12pxspacing/radius/medium -
background#171717context-menu/background -
outline-width1pxspacing/outline/small -
outline-offsetcalc(-1 * var(--spacing-outline-small))on purpose: Composed from a token: the edge sits inside the plate. -
outline-color#3a3a3acontext-menu/edge -
box-shadow0px 16px 24px 0px rgba(0, 0, 0, 0.16)shadow/floating
positionfixed · insetauto · flex-directioncolumn · bordernone · outline-stylesolid · colorinherit
Part of DropdownMenu
MenuItem
One action in a DropdownMenu: a 40px row with its words. Green when it's pointed at or has the focus, red for one that can't be undone.
Install
npx github:Runceanu/rost add menu-item It lands in src/rost/menu-item/, with what it needs and its contract. Install has the rest.
When to use
Things to do to one thing
Edit, Duplicate, Download, Delete: the actions for a row or a card, out of the way until someone wants them.
When not to use
Going somewhere
A list of pages is navigation. That's Menu or Navigation.
Behaviour
Pressing it does the action and closes the DropdownMenu. Pointed at or focused, it turns green, or dark red when it's negative. A disabled one is skipped by the arrow keys' action but can still be reached, so its name is read.
Accessibility
- Element
<button role="menuitem">. A disabled one hasaria-disabled, notdisabled, so it stays in the menu's order. - Colour
The words are 17:1 on the menu's grey, the red ones 6:1, and green on hover 7:1. Disabled words are faint on purpose and not counted.
Content
A verb, and the object when it isn't clear: Delete invoice. No ellipsis unless it opens something that asks more.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
tone | enum | default · negative | default |
disabled | boolean | | false |
icon | slot | | |
children | slot | | |
States: Default, Hover, Focus, Disabled.
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
gap8pxspacing/gap/small -
height40pxspacing/size/medium -
padding-left12pxspacing/gap/small-medium -
padding-right12pxspacing/gap/small-medium -
border-radius8pxspacing/radius/small -
font-family'General Sans Variable'font-family/base -
font-weight400typography/paragraph/font-weight/regular -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing
displayflex · align-itemscenter · inline-size100% · bordernone · backgroundtransparent · outlinenone · cursorpointer · text-alignleft · white-spacenowrap
Changes by variant
8 variants. Each table is what one thing changes with: a column per tone, a row per property. Where every row starts with the same token path, it's written once, under the property.
Follows tone
In 4 variants
| Property | Default | Negative |
|---|---|---|
root.backgroundmenu-item/… | hover/background #006f27 | negative/hover/background #48050c |
Follows tone and state
Default
| Property | Default | Hover | Focus | Disabled |
|---|---|---|---|---|
root.colormenu-item/… | default/label #ededed | hover/label #ededed | hover/label #ededed | disabled/label #555555 |
Negative
| Property | Default | Hover | Focus | Disabled |
|---|---|---|---|---|
root.colormenu-item/… | negative/label #f2705f | negative/hover/label #fee6e1 | negative/hover/label #fee6e1 | disabled/label #555555 |
Only in some variants
These don't change: they're just set in some variants and not others.
Disabled
-
root.cursordefaultFigma frame size