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 initpnpm dlx ermineui inityarn dlx ermineui initbunx ermineui initThen add the component:
npx ermineui add kbdpnpm dlx ermineui add kbdyarn dlx ermineui add kbdbunx ermineui add kbdThat 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
| File | Where it goes |
|---|---|
Kbd.vue | src/components/ui/kbd/Kbd.vue |
index.ts | src/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'