Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

kbd.tsx

38 lines1001 Bytes

1import type * as React from "react";
2​
3import { cn } from "~/lib/utils";
4​
5function Kbd({
6 className,
7 variant = "default",
8 ...props
9}: React.ComponentProps<"kbd"> & {
10 /** `outline` draws a physical key, so the hint stays distinct inside surrounding text. */
11 variant?: "default" | "outline";
12}) {
13 return (
14 <kbd
15 className={cn(
16 "pointer-events-none inline-flex h-5 min-w-5 select-none items-center justify-center gap-1 rounded px-1 font-medium font-sans text-muted-foreground text-xs [&_svg:not([class*='size-'])]:size-3",
17 variant === "outline"
18 ? "border border-b-2 border-foreground/15 px-1.5"
19 : "bg-foreground/[0.07]",
20 className,
21 )}
22 data-slot="kbd"
23 {...props}
24 />
25 );
27​
28function KbdGroup({ className, ...props }: React.ComponentProps<"kbd">) {
29 return (
30 <kbd
31 className={cn("inline-flex items-center gap-1", className)}
32 data-slot="kbd-group"
33 {...props}
34 />
35 );
37​
38export { Kbd, KbdGroup };