On this page

Interaction states

Every control shows when it is hovered, focused, pressed, selected or turned off, so people know what will happen before they act.

People need to see that a button is under the pointer, that the keyboard is on it, that it was pressed, or that it cannot be used right now. Every interactive element has all of these states. Each state has its own colour token, so every component shows it the same way, in light and dark, without extra code.

How it works

  1. Every state uses its own token. Find the token of the element at rest, then add the state: color.background.neutral at rest becomes color.background.neutral.hover on hover and color.background.neutral.pressed when pressed.
  2. Never draw a state with opacity, filter: brightness() or a colour mixed in CSS. One exception: an element with no fill at rest (a row, a menu item, a Subtle button) can sit on any surface, so its hover and pressed tokens are translucent graphite. The build lays each translucent token over every surface and checks the contrast of the text on the result.
  3. Never invent a hover or pressed colour. If the token you need doesn’t exist, ask the design system team to add it.
  4. Keyboard focus is always visible, on every element that can take focus. Hover is never the only way to show something.

Each state

State When Background Text and icon Border
Rest Nothing is happening. The token for the element, such as color.background.neutral or color.background.danger.bold The paired text token (see Pairing) color.border or color.border.bold
Hover A pointer is over the element. The same token plus .hover: one step up the scale Unchanged Unchanged, except a bordered button: color.border.hover
Pressed The element is being clicked or tapped. The same token plus .pressed: two steps up Unchanged Unchanged, except a bordered button: stays on color.border.hover
Focus The element has keyboard focus (:focus-visible). Unchanged Unchanged Add a ring: outline: var(--bh-border-width-focused) solid var(--bh-color-border-focus); outline-offset: var(--bh-state-focus-offset);. A text field instead turns its 1 px border color.border.focus and adds a 2 px inset ring of the same colour inside it (box-shadow: inset 0 0 0 var(--bh-border-width-focused) var(--bh-color-border-focus);): a 3 px solid edge with no gap
Selected The element is chosen, like a table row, a tab or a menu item. color.background.selected, and color.background.selected.hover on hover Unchanged, and a second cue: a check in a menu, or the yellow indicator bar (color.border.selected) Unchanged
Disabled The element cannot be used now. color.background.disabled color.text.disabled, color.icon.disabled color.border.disabled
Read-only A value people can read and copy but not change. None: the value is text, not a field color.text; IDs, keys and URLs in font.code.default None. A copy button sits beside it

The primary button and an ON switch are the exceptions. They rest on graphite 12, the last step, so they have no step above: on hover they move one step back (graphite 11) and when pressed two steps back (graphite 10). Their tokens already do this.

Contrast is checked on the rest, hover and selected fills. The pressed fill is not checked, because it shows only while the pointer or finger is down. Text keeps its rest colour. Borders do too, except the edge of a bordered button, which darkens one step on hover and stays there while pressed, so the button reads as one control as the pointer reaches it.

Rows, menu items and ghost buttons

Elements with no fill at rest use color.background.neutral.subtle, which is transparent. On hover they take color.background.neutral.subtle.hover; when pressed, color.background.neutral.subtle.pressed. Both are translucent, so the hover shows on a white card, a grey panel and an open menu alike.

Rows and menu items keep that light hover so a hovered row never looks selected (color.background.selected is one step darker). A button is never selected, so Subtle and Default buttons take one step more: color.background.neutral.transparent.hover and color.background.neutral.transparent.pressed, which the button reads through button.background.subtle.hover and .pressed. That puts them in the range most design systems use, about 9% and 14% darker than whatever is under them in light.

Disabled

  • Use the three disabled colour tokens above. Don’t lower the opacity.
  • Remove the pointer and keyboard interaction (disabled on native controls, aria-disabled="true" plus blocked events on others) and show cursor: not-allowed.
  • WCAG doesn’t require contrast for disabled controls, so the disabled colours are light on purpose.
  • Prefer telling people why something can’t be used, for example in helper text, over a silent disabled control.

Read-only values

  • Show a value people cannot change as text, not as an input box. A box with a border says “type here”, and a read-only input still takes focus and shows the focus ring when clicked.
  • Put IDs, keys and URLs in font.code.default, with a copy button beside them, and keep the label next to the value.
  • Use a disabled field only for a value that can be changed in the same form but not right now, and say why.

Dark mode

The same tokens work in dark. In dark, fills get lighter on hover and when pressed instead of darker, and the primary button moves back from graphite 12 the same way; the tokens already do this, so the code doesn’t change.

Do and don’t

Do

Show the selected item with the selected fill and the yellow bar, so it doesn’t rely on colour.

Don’t

Don’t show selection with a text colour alone. People with low colour vision can’t see it.

Do

Keep the focus ring: 2 px, 2 px outside the control, on every element that takes focus.

Don’t

Don’t replace the focus ring with a hover fill. Keyboard users lose track of where they are.

Do

Show hover with the hover token, one step along the scale.

Don’t

Don’t fade a control to show a state. The background shows through and the text loses contrast.

Tokens

The colours are on the Color page. The focus ring width, border.width.focused, is on the Border page. This group holds the gap between a control and its ring.

TokenValueDescription
--bh-state-focus-offset2px2 px. Gap between a control and its focus ring. The ring is drawn outside; inside a box that clips it (menu items, table cells, tabs in a scroll area) use the negative value.