Vitral 0.2.18
Misc

Kbd

A key or a shortcut as it looks on the reader’s own keyboard: ⌘ on a Mac, Ctrl everywhere else, each symbol still named for a screen reader.

Import

main.ts
import { Kbd } from '@vitral/vue';

Shortcuts

`mod` is the platform's command key. The page asks the browser which platform it is on once it is mounted, so a server render and the first paint agree.

Open the command palette with CtrlK, save with CtrlS, and find anything with CtrlShiftF.

<script setup lang="ts">import { Kbd } from '@vitral/vue';</script> <template>    <p style="margin: 0">Open the command palette with <Kbd keys="mod+k" />, save with <Kbd keys="mod+s" />, and find anything with <Kbd keys="mod+shift+f" />.</p></template>

Platforms

`platform` pins the names, for documentation written about one platform.

macOSCommandOptionShiftPWindows and LinuxCtrlAltShiftP
<script setup lang="ts">import { Kbd } from '@vitral/vue';</script> <template>    <div style="display: grid; grid-template-columns: auto auto; gap: 0.75rem 1.5rem; align-items: center; justify-content: start">        <span>macOS</span>        <Kbd keys="mod+alt+shift+p" platform="mac" />        <span>Windows and Linux</span>        <Kbd keys="mod+alt+shift+p" platform="other" />    </div></template>

Sizes and single keys

ShiftEnterShiftEnterShiftEnterEscGI
<script setup lang="ts">import { Kbd } from '@vitral/vue';</script> <template>    <div style="display: flex; flex-wrap: wrap; gap: 1rem; align-items: center">        <Kbd keys="shift+enter" size="small" />        <Kbd keys="shift+enter" />        <Kbd keys="shift+enter" size="large" />        <Kbd>Esc</Kbd>        <Kbd :keys="['g', 'i']" separator="then" />    </div></template>

API

Read from packages/vue/src/components/Kbd/types.ts, so it says what the component actually accepts.

Props

NameTypeDescription
keys string | string[]The shortcut: `'mod+k'`, `'shift+enter'`, or the keys as an array. `mod` is ⌘ on a Mac and Ctrl elsewhere, and the modifiers are drawn as each platform draws them. The default slot replaces it for a single key.
separator stringDrawn between the keys. Defaults to none on a Mac, where ⌘⇧P is read as one, and `'+'` elsewhere.
platform 'auto' | 'mac' | 'other'Which platform's names to use; `'auto'` (the default) asks the browser once mounted.
size Size—

Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.

Slots

NameSlot propsDescription
default —One key's text, in place of `keys`.