vael-ui v0.5.7

Data display

Layout

Kbd

A keyboard key or shortcut, styled like a physical key. Use it in hints and help text.

Install

import { Kbd } from 'vael-ui'

Playground

⌘K
Usage
<script setup lang="ts">
import { Kbd } from 'vael-ui'
</script>

<template>
  <Kbd>⌘K</Kbd>
</template>

Props

NameTypeDefaultDescription
motionKbdMotionHow it moves: its appearance ({ initial: { root: { opacity: 0, y: 2 } } }). false turns its own animation off.
uiPartial<Record<'root', UiPartValue>>Class and style overrides for each part.

Events

No events.

Slots

NameTypeDescription
defaultanyKey or shortcut text, e.g. ⌘ or Esc.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

Kbd: its appearance.

<Kbd
  :motion="{ initial: { root: { opacity: 0, y: 4 } } }"
/>
NameTypeDescription
initialexitrootSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

It has no keyboard interaction of its own.

  • Kbd renders a native <kbd> element with no role and no keyboard handling. Screen readers read the text you put in it.