Kbd/kbd-platform-specific-

PreviousNext

A kbd/kbd-platform-specific- example

Docs
shadcnblocksblock

Preview

Loading preview…
code/example/kbd/kbd-platform-specific-4.tsx
"use client";

import { Kbd, KbdGroup } from "@/components/ui/kbd";

export const title = "Platform-Aware Shortcut";

const Example = () => {
  const isMac =
    typeof window !== "undefined" &&
    navigator.platform.toUpperCase().indexOf("MAC") >= 0;

  return (
    <div className="rounded-md border bg-background p-4">
      <KbdGroup>
        <Kbd>{isMac ? "⌘" : "Ctrl"}</Kbd>
        <Kbd>K</Kbd>
      </KbdGroup>
    </div>
  );
};

export default Example;

Installation

npx shadcn@latest add @shadcnblocks/kbd-kbd-platform-specific-4

Usage

import { KbdKbdPlatformSpecific4 } from "@/components/kbd-kbd-platform-specific-4"
<KbdKbdPlatformSpecific4 />