Skip to content
iv-ui v0.3.0

Shortcut

since 0.2.0

Renders a keyboard combination as key caps.

import { Shortcut } from '@elluzion/iv-ui';

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>
  • keys accepts a single key or an ordered array.
  • label supplies the accessible name for the combination.
  • Use inside menus, command palettes, and help panels.

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>
import { Shortcut } from '@elluzion/iv-ui';

Props

4 props · 0 events · 0 snippets
PropTypeDefaultDescription
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.
  • The component renders <kbd> elements, which assistive technology recognizes.
  • Pass label when the visual key names are symbols rather than words.
  • Keys are rendered in order; keep the platform convention, such as Control before K.
Class hooks
.iv-key.iv-md.iv-root
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records