Shortcut
Renders a keyboard combination as key caps.
import { Shortcut } from '@elluzion/iv-ui'; 01 Preview
Single key
One key cap.
Press Esc to close the palette.
Source· svelte Show Hide
<script lang="ts">
import { Shortcut } from '@elluzion/iv-ui';
</script>
<p class="line">Press <Shortcut keys="Esc" /> to close the palette.</p>
<style>
.line {
display: flex;
align-items: center;
gap: var(--iv_spacing-sm);
margin: 0;
font-family: var(--iv_font-mono);
font-size: var(--iv_text-body);
color: var(--iv_foreground-dim);
}
</style>02 Usage
keysaccepts a single key or an ordered array.labelsupplies the accessible name for the combination.- Use inside menus, command palettes, and help panels.
03 Examples
Combinations
Modifier keys in order, with the accessible name spelled out.
Command palette ⌘K
Search files CtrlShiftP
Toggle sidebar ⌘B
Source· svelte Show Hide
<script lang="ts">
import { Shortcut } from '@elluzion/iv-ui';
</script>
<div class="stack">
<p class="line">
Command palette <Shortcut keys={['⌘', 'K']} label="Command K" />
</p>
<p class="line">
Search files <Shortcut keys={['Ctrl', 'Shift', 'P']} label="Control Shift P" />
</p>
<p class="line">
Toggle sidebar <Shortcut keys={['⌘', 'B']} label="Command B" />
</p>
</div>
<style>
.stack {
display: flex;
flex-direction: column;
gap: var(--iv_spacing-md);
}
.line {
display: flex;
align-items: center;
gap: var(--iv_spacing-sm);
margin: 0;
font-family: var(--iv_font-mono);
font-size: var(--iv_text-body);
color: var(--iv_foreground-dim);
}
</style>Sizes
sm inside menus, md for help panels.
⌘K ⌘K
Source· svelte Show Hide
<script lang="ts">
import { Shortcut } from '@elluzion/iv-ui';
</script>
<div class="row">
<Shortcut keys={['⌘', 'K']} />
<Shortcut keys={['⌘', 'K']} size="md" />
</div>
<style>
.row {
display: flex;
align-items: center;
gap: var(--iv_spacing-lg);
}
</style>04 API
import { Shortcut } from '@elluzion/iv-ui';Props
4 props · 0 events · 0 snippets| Prop | Type | Default | Description |
|---|---|---|---|
| keys required | string | string[] | — | Key or keys to display, in order. |
| label | string | '' | Accessible name for the combination. |
| size | 'sm' | 'md' | 'sm' | Key cap size. |
| className | string | '' | Extra classes merged onto the root element. |
05 Accessibility
- The component renders
<kbd>elements, which assistive technology recognizes. - Pass
labelwhen the visual key names are symbols rather than words. - Keys are rendered in order; keep the platform convention, such as Control before K.
06 Tokens & CSS hooks
Tokens used
Class hooks
.iv-key.iv-md.iv-root