Kbd

A key or key combination shown as a keycap, for shortcuts in text and menus.

Install

If this is the first component in the project, set up once. This writes ermine.json and copies the theme stylesheet. The installation guide covers Vue, Nuxt and Astro.

npx ermineui init
pnpm dlx ermineui init
yarn dlx ermineui init
bunx ermineui init

Then add the component:

npx ermineui add kbd
pnpm dlx ermineui add kbd
yarn dlx ermineui add kbd
bunx ermineui add kbd

That copies 2 files into src/components/ui/kbd/. Files you already have are kept.

Use

import { Kbd } from '@/components/ui/kbd'
<script setup lang="ts">
import { Kbd } from '@/components/ui/kbd'
</script>

<template>
  <Kbd />
</template>

In Nuxt, with the auto-import setting, the tags work in templates without the import. In Astro, use it inside a Vue island. The props are documented in the source below, on each one.

What gets copied

FileWhere it goes
Kbd.vuesrc/components/ui/kbd/Kbd.vue
index.tssrc/components/ui/kbd/index.ts

The folders are the suggested ones. ermine.json says where yours are.

Source

This is exactly what the command copies. To install by hand, create each file below and the helpers listed above.

Kbd.vue 28 lines
<template>
  <kbd class="er-kbd"><slot /></kbd>
</template>

<style>
@layer components {
  .er-kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.375rem;
    height: 1.375rem;
    padding: 0 0.3125rem;
    border: 1px solid var(--er-border);
    border-bottom-width: 2px;
    border-radius: var(--er-radius-sm);
    background: var(--er-muted);
    color: var(--er-muted-foreground);
    font-family: var(--er-font-sans);
    font-size: 0.6875rem;
    font-weight: var(--er-weight-medium);
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
  }
}
</style>
index.ts 3 lines
/** Kbd — a key or key combination shown as a keycap, for shortcuts in text and menus. */
export { default as Kbd } from './Kbd.vue'