Components › Components

On this page

Kbd

A key to press, as in Ctrl K.

Search with Ctrl K.

Usage #

tscl
@import uiKbd from './kbd.tscl'

<div class="demo">
  <p>Search with <uiKbd>Ctrl</uiKbd> <uiKbd>K</uiKbd>.</p>
</div>

<style scoped>
  :scope {
    display: grid;
    gap: 12px;
    padding: 24px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-bg);
    color: var(--ui-fg);
  }
  p {
    margin: 0;
  }
</style>

Source #

Copy it into your components folder (next to the others) as kbd.tscl.

tscl
{{-- Kbd: a key to press. --}}

<kbd data-part="kbd"><slot /></kbd>

<style scoped>
  @layer theme, base, components, utilities;
  @layer components {
    :where(:scope) {
      display: inline-block;
      min-width: 1.6em;
      padding: 1px 6px;
      border: 1px solid var(--ui-border);
      border-bottom-width: 2px;
      border-radius: 4px;
      background: var(--ui-bg);
      color: var(--ui-fg);
      font: calc(var(--ui-font-size) - 2px)/1.5 var(--ui-font-mono);
      text-align: center;
    }
  }
</style>

Styling #

Needs #