Keycap for keyboard shortcuts using the native kbd element, in two sizes, with key combinations rendered as separate keys.
Press Ctrl+K to search, or Esc to close.
Press Ctrl+K to search, or Esc to close.
Press Ctrl+K to search, or Esc to close.
Press Ctrl+K to search, or Esc to close.
Press Ctrl+K to search, or Esc to close.
<p class="flex flex-wrap items-center gap-1.5 text-sm text-ink">
Press <x-markas.kbd :keys="['Ctrl', 'K']" /> to search, or <x-markas.kbd>Esc</x-markas.kbd> to close.
</p>import { Kbd } from "@/components/markas/Kbd";
export default function KbdExample() {
return (
<p className="flex flex-wrap items-center gap-1.5 text-sm text-ink">
Press <Kbd keys={["Ctrl", "K"]} /> to search, or <Kbd>Esc</Kbd> to close.
</p>
);
}<script setup lang="ts">
import Kbd from "@/components/markas/Kbd.vue";
</script>
<template>
<p class="flex flex-wrap items-center gap-1.5 text-sm text-ink">
Press <Kbd :keys="['Ctrl', 'K']" /> to search, or <Kbd>Esc</Kbd> to close.
</p>
</template><script lang="ts">
import Kbd from "$lib/components/markas/Kbd.svelte";
</script>
<p class="flex flex-wrap items-center gap-1.5 text-sm text-ink">
Press <Kbd keys={["Ctrl", "K"]} /> to search, or <Kbd>Esc</Kbd> to close.
</p>---
import Kbd from "@/components/markas/Kbd.astro";
---
<p class="flex flex-wrap items-center gap-1.5 text-sm text-ink">
Press <Kbd keys={["Ctrl", "K"]} /> to search, or <Kbd>Esc</Kbd> to close.
</p>Examples
Sizes
<div class="flex flex-wrap items-center gap-6">
<div class="flex items-center gap-2">
<x-markas.kbd size="sm">Enter</x-markas.kbd>
<x-markas.kbd size="sm" :keys="['Shift', 'Tab']" />
</div>
<div class="flex items-center gap-2">
<x-markas.kbd>Enter</x-markas.kbd>
<x-markas.kbd :keys="['Shift', 'Tab']" />
</div>
</div>Shortcut list
- Search
- Ctrl+K
- New document
- Ctrl+Alt+N
- Go to next page
- GthenN
- Show shortcuts
- ?
- Search
- Ctrl+K
- New document
- Ctrl+Alt+N
- Go to next page
- GthenN
- Show shortcuts
- ?
- Search
- Ctrl+K
- New document
- Ctrl+Alt+N
- Go to next page
- GthenN
- Show shortcuts
- ?
- Search
- Ctrl+K
- New document
- Ctrl+Alt+N
- Go to next page
- GthenN
- Show shortcuts
- ?
- Search
- Ctrl+K
- New document
- Ctrl+Alt+N
- Go to next page
- GthenN
- Show shortcuts
- ?
In a search button
<button type="button" class="flex h-10 w-full items-center gap-2 rounded-lg border border-line bg-surface px-3 text-sm text-muted transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none">
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="7" /><path d="m20 20-3.5-3.5" /></svg>
<span>Search docs</span>
<x-markas.kbd size="sm" :keys="['Ctrl', 'K']" class="ml-auto" aria-hidden="true" />
</button>Installation
npx markasui@latest add kbdpnpm dlx markasui@latest add kbdyarn dlx markasui@latest add kbdbunx --bun markasui@latest add kbd- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
resources/views/components/markas/kbd.blade.php.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Kbd.tsx.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Kbd.vue.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/lib/components/markas/Kbd.svelte.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Kbd.astro.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/app/markas/kbd.component.ts.
Usage
<x-markas.kbd>Esc</x-markas.kbd>
<x-markas.kbd :keys="['Ctrl', 'K']" />
<x-markas.kbd size="sm" :keys="['G', 'N']" separator="then" />import { Kbd } from "@/components/markas/Kbd";
<Kbd>Esc</Kbd>
<Kbd keys={["Ctrl", "K"]} />
<Kbd size="sm" keys={["G", "N"]} separator="then" /><template>
<Kbd>Esc</Kbd>
<Kbd :keys="['Ctrl', 'K']" />
<Kbd size="sm" :keys="['G', 'N']" separator="then" />
</template><script lang="ts">
import Kbd from "$lib/components/markas/Kbd.svelte";
</script>
<Kbd>Esc</Kbd>
<Kbd keys={["Ctrl", "K"]} />
<Kbd size="sm" keys={["G", "N"]} separator="then" />---
import Kbd from "@/components/markas/Kbd.astro";
---
<Kbd>Esc</Kbd>
<Kbd keys={["Ctrl", "K"]} />
<Kbd size="sm" keys={["G", "N"]} separator="then" />import { Component } from "@angular/core";
import { Kbd } from "./markas/kbd.component";
@Component({
selector: "app-example",
imports: [Kbd],
template: `
<kbd markas-kbd>Esc</kbd>
<kbd markas-kbd [keys]="['Ctrl', 'K']"></kbd>
<kbd markas-kbd size="sm" [keys]="['G', 'N']" separator="then"></kbd>
`,
})
export class Example {}Angular uses an attribute selector on the native kbd, so class and aria-hidden stay on it.
- No JavaScript needed. The Blade version does not need Alpine.js.
keysrenders<kbd>. Without<kbd>Ctrl </kbd> <span>+</span> <kbd>K </kbd> </kbd> keys, the slot or children fill a single keycap.- Inside a button that already has a name, add
aria-hidden="true"so the shortcut is not read twice. - The default separator is ”+”. Change it with
separator, for example “then” for key sequences.
Props
| Name | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'md' | md | Keycap height and text size. Use sm inside buttons and inputs. |
keys | string[] | [] | Key combination. Each key renders as its own keycap inside an outer kbd. Replaces the slot or children. |
separator | string | + | Muted text between the keys of a combination, such as "then" for a key sequence. |
children / slot | ReactNode / slot / snippet | - | Content of a single keycap when keys is empty. |
Accessibility
- Uses the native kbd element; a combination nests one kbd per key inside an outer kbd, as the HTML spec recommends.
- The separator is plain text, so screen readers announce combinations such as "Ctrl + K".
- Set aria-hidden on the keycap when the shortcut is only a visual hint inside a control that already has a name.
Related components
More data components with the same classes in every framework.
- AvatarRound profile photo in three sizes, with name initials as a fallback when the image is empty or fails to load.
- CardCard that groups content with an optional title, description, body, and footer.
- CarouselRow of slides built on CSS scroll snap, with previous and next buttons, optional dots, and arrow key navigation. No autoplay.
- Code BlockMonospace code block with an optional file name, line numbers, and a copy button. Plain text, no syntax highlighting.
- Scroll AreaScrollable container with a thin token-styled scrollbar that keyboard users can focus and scroll. No JavaScript.
- SeparatorHorizontal or vertical dividing line, decorative by default, with an optional label in the middle such as "or".