Displays a keyboard key, such as a modifier, a letter, or an icon. Renders a kbd element.
<script lang="ts">
import { Kbd } from "#lib/components/ui/kbd/index.js";
import { CommandIcon } from "@lucide/svelte";
</script>
<Kbd>⌘</Kbd>
<Kbd>Ctrl</Kbd>
<Kbd><CommandIcon /></Kbd>pnx remote0 add https://plainsv.com/r/kbd.jsonWrap the keys of a shortcut in KbdGroup. It renders a kbd that holds the key elements, which is how HTML marks keys pressed together. Place text such as + between keys when the platform needs it.
Use ⌘K to open the command menu, or Ctrl+B to toggle the sidebar.
<script lang="ts">
import { Kbd, KbdGroup } from "#lib/components/ui/kbd/index.js";
</script>
<p>
Use <KbdGroup><Kbd>⌘</Kbd><Kbd>K</Kbd></KbdGroup> to open the command menu.
</p>Place a key inside a Button to hint at its shortcut.
<script lang="ts">
import { Kbd } from "#lib/components/ui/kbd/index.js";
import { Button } from "#lib/components/ui/button/index.js";
import { CornerDownLeftIcon } from "@lucide/svelte";
</script>
<Button variant="outline">Accept <Kbd><CornerDownLeftIcon /></Kbd></Button>Set size to xs, sm, md, or lg. The default is md, a 20 pixel key like the shadcn kbd.
<Kbd size="lg">⌘</Kbd>The corner radius stays one step smaller than the size, so keys keep square corners. Set rounded to xs through 4xl or pill to override it.
<Kbd rounded="pill">⌘</Kbd>Kbd and KbdGroup extend the native kbd attributes.
interface Props extends CompPropsWithChild<"kbd"> {
/** Height, padding, text, and icon size on the shared scale; defaults to `md` */
size?: UiSize;
/** Corner radius; one step smaller than `size` when omitted, like shadcn, so the key stays square-cornered */
rounded?: UiRounded;
}
interface GroupProps extends CompPropsWithChild<"kbd"> {}