Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Mac Keyboard, animated React component

A Mac keyboard drawn in HTML, in silver or space grey. Press a key and it sinks, squashes and springs back while a ring of backlight spreads out from it through the gaps; it can listen to the real keyboard, plays a recorded mechanical click for each key the instant it goes down, and shows what you type in a strip above.

  • Free
  • Motion Effects
  • Spring

Silver, typing on its own

Space grey, listening to your keyboard

Like Mac Keyboard? 256 more are in Pro.

Pro unlocks all 256 Pro components, every template and block, and everything we release next. Mac Keyboard stays free.

Play with it

Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.

Start typing...
Type on your keyboard, or tap the keys.

Props

PropTypeDefaultWhat it does
layout"mac"Full layout with the Esc and F-key row, or compact without it.
theme"auto"Space grey, silver, or follow the page's dark class.
listenfalseReacts to the real keyboard: keys sink, ripple, click and type. With several listening keyboards on a page, only one answers: the last one pressed or hovered, else the one nearest the middle of the screen.
showOutputtrueShows a strip above the keys with what has been typed. Return clears it.
placeholder"Start typing..."Text in the strip before anything is typed.
autoplayfalseTypes autoplayText on the keys again and again until someone presses a key.
autoplayText"hello, nexus"What the demo types.
accent"#0a84ff"Colour of the backlight ripple.
enableSoundtruePlays a key click the moment a key goes down (not during autoplay).
soundSrc"/sounds/keys.ogg"Recorded Cherry MX clicks, one per key. Put keys.ogg in public/sounds; until it loads, or if it is missing, the synthesised click plays. Pass "" to always synthesise.
soundType"mechanical"Timbre of the synthesised click (used when there is no recording).
volume0.6Click volume, 0 to 1.
showFunctionRowtrueShows the Esc and F-key row (mac layout).
activeKeys[]KeyboardEvent.code values to show as held, e.g. from usePhysicalKeyboard().
onKeyPress—Fires when a key on screen is pressed.
className—Extra classes on the keyboard body.
keyClassName—Extra classes on every keycap.

Add it to your project

  1. 1

    Set up your project once

    You need a Next.js project with Tailwind CSS and the @/ import alias. In its root folder, run this once. It creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 2

    Connect the registry

    Run this once per project. It writes the Nexus UI entry into components.json for you:

    npx shadcn@latest registry add "@nexus-labs=https://www.nexus-ui.com/api/registry/{name}"

    Type it exactly as shown. {name} is filled in by the CLI with the component you ask for, so you never replace it.

  1. 3

    Add the component

    Run this from your project root. It adds the component, the helpers it imports and its npm packages.

    npx shadcn@latest add @nexus-labs/mac-keyboard
  2. 4

    Check what was added

    With a project made as in the Quick Start (a src/ folder), these files land in it:

    components/
    key-sound/
    index.ts
    key-sound-slices.ts
    key-sound.ts
    use-key-sound.ts
    keyboard/
    index.ts
    keyboard-key.tsx
    keyboard-layout.ts
    keyboard.tsx
    use-keyboard-sound.ts
    mac-keyboard.tsx
  3. 5

    Copying by hand? Skip the registry

    Instead of steps 2 and 3 you can copy the files yourself, with no registry and no API key. Step 1 still applies, so that cn() exists. Install the packages:

    npm install framer-motion

    Then show the source and create each file at the path it gives:

  4. 6

    Use it in a page

    Installing only adds the files. Import the component in a page and render it. The Usage tab on the preview shows a fuller example with props:

    // src/app/page.tsx
    import { MacKeyboard } from "@/components/keyboard";
    
    export default function Page() {
      return (
        <main>
          <MacKeyboard />
        </main>
      );
    }

Like Mac Keyboard? 256 more are in Pro.

Pro unlocks all 256 Pro components, every template and block, and everything we release next. Mac Keyboard stays free.

About Mac Keyboard

The Mac Keyboard component renders an animated replica of a standard Apple keyboard layout with spring-animated key press physics. Individual keys depress with a Framer Motion spring transition on hover, matching the physical press feel of a real keyboard. Use it in developer tool demos to illustrate keyboard shortcuts, in documentation to highlight key bindings, or as a decorative product visual that communicates the tool is built for keyboard-first users.

Good for

  • Keyboard shortcut documentation pages
  • Developer tool feature illustrations
  • Interactive onboarding guides
  • CLI and terminal tool marketing pages

Mac Keyboard questions

How do I install the Mac keyboard?

Run `npx shadcn@latest add @nexus-labs/mac-keyboard`. It installs framer-motion. For the recorded key clicks, copy `keys.ogg` (about 200 KB) into `public/sounds/`; without it the keys use a click synthesised with the Web Audio API, so nothing breaks.

How do I highlight keys as the user types?

Call the exported `usePhysicalKeyboard()` hook and pass its result to `activeKeys`. Keys matching the pressed `KeyboardEvent.code` values show as held down.

Which sound options are there?

`enableSound` turns sound on or off, `soundType` picks "mechanical", "soft" or "clicky", and `volume` goes from 0 to 1. Sounds play when virtual keys are clicked, and `onKeyPress` gives you the key that was pressed.

Can I change the layout and theme?

`layout` is "mac" or "compact", `showFunctionRow` hides the Esc and F-key row, and `theme` is "dark", "light" or "auto", which follows the `dark` class on the html element.