Key Hints

View as Markdown

The strip of keys at the foot of a palette or a viewer, such as ↑ ↓ Move, hidden on touch screens.

  • ENG-2140 Exports fail for large workspaces
  • Q1 onboarding revamp
  • Priya Raman
  • Up arrow or Down arrow: Move
  • Return: Open
  • Command Return: Open in new tab
  • Escape: Close

When to use

The strip of keys at the foot of a palette or a viewer, such as ↑ ↓ Move, hidden on touch screens. Use Kbd instead when you show one shortcut beside its command.

Usage

import { KeyHints } from "./ui/uicontext/components/KeyHints.ts"
export const Footer = <M>(h: Html.H<M>) =>	KeyHints(h, { hints: [{ keys: ["up", "down"], label: "Move" }, { keys: "enter", label: "Open" }, { keys: "esc", label: "Close" }] })

Examples

Hidden on touch screens

Without touch, the strip hides on phones and tablets, where nobody presses these keys.

  • Left arrow or Right arrow: Previous and next
  • Space: Zoom
  • D: Download

API reference

Options

KeyHints options
NameTypeDefaultDescription
hintsrequiredKeyHint[]—The hints, in order.
labelstring—Names the list for a screen reader; "Keyboard shortcuts" by default.
variant"plain" | "bar"—bar draws a line above, for the foot of a dialog or a panel.
align"start" | "end"startWhich end of the row the hints sit at; start by default.
touchboolean—Keeps the strip on touch screens too, for a tablet with a keyboard.
macbooleantrue⌘ on a Mac, Ctrl elsewhere; true by default.
styleStyle——

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/key-hints

Source