Components
Keyboard input
A key cap that shows a keyboard shortcut in a line of text, a menu row or a button.
K7↵Esc
import { Kbd } from '@dex/shared/components/kbd'
export function KbdKeys() {
return (
<>
<Kbd>K</Kbd>
<Kbd>7</Kbd>
<Kbd>↵</Kbd>
<Kbd>Esc</Kbd>
</>
)
}
CommandShiftOptionControl
import { Kbd } from '@dex/shared/components/kbd'
export function KbdModifiers() {
return (
<>
<Kbd meta />
<Kbd shift />
<Kbd alt />
<Kbd ctrl />
</>
)
}
CommandKShiftCommandPCommand↵
import { Kbd } from '@dex/shared/components/kbd'
export function KbdCombinations() {
return (
<>
<Kbd meta>K</Kbd>
<Kbd meta shift>
P
</Kbd>
<Kbd meta>↵</Kbd>
</>
)
}
import { Button } from '@dex/shared/components/button'
import { Kbd } from '@dex/shared/components/kbd'
export function KbdInAButton() {
return (
<>
<Button aria-keyshortcuts="Meta+Enter Control+Enter">
Send to the Dex team
<Kbd meta aria-hidden>
↵
</Kbd>
</Button>
<Button variant="outline" aria-keyshortcuts="Meta+K Control+K">
Search roles
<Kbd meta aria-hidden>
K
</Kbd>
</Button>
</>
)
}
import { Button } from '@dex/shared/components/button'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@dex/shared/components/dropdown-menu'
import { Kbd } from '@dex/shared/components/kbd'
export function KbdInAMenu() {
return (
<DropdownMenu>
<DropdownMenuTrigger render={<Button variant="outline" />}>Role actions</DropdownMenuTrigger>
<DropdownMenuContent align="start" className="w-56">
<DropdownMenuItem aria-keyshortcuts="Meta+S Control+S">
Save role
<Kbd meta aria-hidden className="ml-auto text-muted-foreground">
S
</Kbd>
</DropdownMenuItem>
<DropdownMenuItem aria-keyshortcuts="Meta+Enter Control+Enter">
Apply
<Kbd meta aria-hidden className="ml-auto text-muted-foreground">
↵
</Kbd>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)
}
Press Command↵ to send your answers.
import { Kbd } from '@dex/shared/components/kbd'
export function KbdInProse() {
return (
<p className="text-base leading-6 text-foreground">
Press <Kbd meta>↵</Kbd> to send your answers.
</p>
)
}
- Set modifiers with the
meta,shift,altandctrlprops, not by typing ⌘ or Ctrl as the child. The props are what give each platform its own keys and order. - Inside a control, give the cap
aria-hiddenand put the shortcut on the control witharia-keyshortcuts, so it is not read out as part of the label. - In a line of text, leave the cap readable. A screen reader hears the names of the keys: "Command", "Shift".