Rost

← All components

component

Command

A palette for doing anything from the keyboard: a search field over the page, and the commands under it in groups, narrowing as you type.

In code Contract: review Guidance: proposed Contract on GitHub Figma 758:10 As markdown

Try it

Every variant

Default

Install

npx github:Runceanu/rost add command

It lands in src/rost/command/, with what it needs and its contract. Install has the rest.

When to use

  • Everywhere from one key

    Jumping to any page or starting any task without the mouse: Go to Invoices, New client. Open it with ⌘K and say so somewhere with a Kbd.

When not to use

Behaviour

It opens over the page with the focus in the search field. Typing keeps the commands whose name contains what was typed, and hides a group with nothing left. Up and Down move the green highlight across the groups, Enter runs the command and closes it, Esc closes it without running anything.

Accessibility

  • Element

    A modal <dialog> named by label. The search is role="combobox" pointing at the list with aria-activedescendant; each group is role="group" named by its label, each command a ComboboxOption.

  • Keyboard

    The focus stays in the search field; the highlight moves in the list.

  • Colour

    The search text is 17:1 on the plate, the group names and the empty-list words 7:1.

Content

Commands start with a verb or say where they go: New invoice, Go to Clients.

Props

PropTypeValuesDefault
open boolean false
groups node
placeholder string Type a command or search
empty string No match
label string Command

States: Default, Focus.

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

  • padding 0px spacing/gap/none
  • inset-block-start 96px spacing/gap/7xlarge

bordernone · backgroundtransparent · overflowvisible · max-widthnone · margin0 auto auto · colorinherit

backdrop

  • background #060805 command/backdrop
  • opacity 0.72 opacity/hard

panel

  • width 480px no token yet
  • border-radius 16px spacing/radius/large
  • background #171717 command/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 command/edge
  • box-shadow 0px 16px 24px 0px rgba(0, 0, 0, 0.16) shadow/floating

displayflex · flex-directioncolumn · max-widthcalc(100vw - 32px) · overflowhidden · outline-stylesolid

search

  • height 56px spacing/size/large
  • padding-left 16px spacing/gap/medium
  • padding-right 16px spacing/gap/medium
  • border-bottom-width 1px spacing/outline/small
  • border-bottom-color #747573 command/search-line
  • 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
  • color #ededed command/search

displayblock · width100% · bordernone · border-bottom-stylesolid · backgroundtransparent · outlinenone

search-placeholder

  • color #999999 command/placeholder

list

  • max-height 320px no token yet
  • padding 4px spacing/gap/2xsmall

displayflex · flex-directioncolumn · overflow-yauto

group-label

  • padding-top 8px spacing/gap/small
  • padding-bottom 4px spacing/gap/2xsmall
  • padding-left 12px spacing/gap/small-medium
  • font-family 'General Sans Variable' font-family/base
  • font-weight 400 typography/label/font-weight/regular
  • font-size 12px typography/label/font-size
  • line-height 14px typography/label/line-height
  • letter-spacing 0px typography/label/letter-spacing
  • color #999999 command/group-label

empty

  • height 40px spacing/size/medium
  • padding-left 12px spacing/gap/small-medium
  • 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
  • color #999999 command/empty

displayflex · align-itemscenter

Only in some variants

These don't change: they're just set in some variants and not others.

Every variant

  • search.border-bottom-color #ededed command/search-line-focus
  • search.border-bottom-width 2px spacing/outline/medium