---
title: "Shortcut"
description: "Renders a keyboard combination as key caps."
category: "Display & Misc"
slug: shortcut
url: /components/shortcut
since: "0.2.0"
status: "stable"
---

# Shortcut

Renders a keyboard combination as key caps.

## Import

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

## Preview

One key cap.

```svelte
<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>
```

## Usage

- `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.

## Examples

### Combinations

Modifier keys in order, with the accessible name spelled out.

```svelte
<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.

```svelte
<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>
```

### Props

| 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. |

### Tokens used

`--iv_border` · `--iv_font-mono` · `--iv_foreground-dim` · `--iv_leading-none` · `--iv_radius-sm` · `--iv_surface-elevated` · `--iv_text-sm` · `--iv_text-xs`

See the [token reference](/foundations/tokens.md) for values.

### CSS hooks

`.iv-key` · `.iv-md` · `.iv-root`

## Accessibility

- 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.

## Related

- [Menu](/components/menu.md)
- [Tooltip](/components/tooltip.md)
- [Badge](/components/badge.md)
- [Button](/components/button.md)