Rost

← All components

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.

In code Contract: review Guidance: proposed Contract on GitHub Figma 755:25 As markdown
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

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 has aria-haspopup="menu" and aria-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

PropTypeValuesDefault
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

  • margin 0px spacing/gap/none
  • margin-block-start 8px spacing/gap/small
  • min-width 180px no token yet
  • padding 4px spacing/gap/2xsmall
  • border-radius 12px spacing/radius/medium
  • background #171717 dropdown-menu/background
  • outline-width 1px spacing/outline/small
  • outline-offset calc(-1 * var(--spacing-outline-small)) on purpose: Composed from a token: the edge sits inside the plate.
  • outline-color #3a3a3a dropdown-menu/edge
  • box-shadow 0px 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

  • height 1px spacing/outline/small
  • margin-top 4px spacing/gap/2xsmall
  • margin-bottom 4px spacing/gap/2xsmall
  • background #3a3a3a dropdown-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.

In code Contract: review Guidance: proposed Contract on GitHub Figma 781:5 As markdown

Try it

Every variant

Default

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

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

PropTypeValuesDefault
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

  • margin 0px spacing/gap/none
  • min-width 180px no token yet
  • padding 4px spacing/gap/2xsmall
  • border-radius 12px spacing/radius/medium
  • background #171717 context-menu/background
  • outline-width 1px spacing/outline/small
  • outline-offset calc(-1 * var(--spacing-outline-small)) on purpose: Composed from a token: the edge sits inside the plate.
  • outline-color #3a3a3a context-menu/edge
  • box-shadow 0px 16px 24px 0px rgba(0, 0, 0, 0.16) shadow/floating

positionfixed · insetauto · flex-directioncolumn · bordernone · outline-stylesolid · colorinherit

Part of DropdownMenu

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.

In code Contract: review Guidance: proposed Contract on GitHub Figma 755:23 As markdown
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

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 has aria-disabled, not disabled, 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

PropTypeValuesDefault
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

  • gap 8px spacing/gap/small
  • height 40px spacing/size/medium
  • padding-left 12px spacing/gap/small-medium
  • padding-right 12px spacing/gap/small-medium
  • border-radius 8px spacing/radius/small
  • font-family 'General Sans Variable' font-family/base
  • font-weight 400 typography/paragraph/font-weight/regular
  • font-size 14px typography/paragraph/font-size
  • line-height 20px typography/paragraph/line-height
  • letter-spacing 0px typography/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

PropertyDefaultNegative
root.backgroundmenu-item/… hover/background #006f27 negative/hover/background #48050c

Follows tone and state

Default

PropertyDefaultHoverFocusDisabled
root.colormenu-item/… default/label #ededed hover/label #ededed hover/label #ededed disabled/label #555555

Negative

PropertyDefaultHoverFocusDisabled
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.cursor default Figma frame size