Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Command Palette, animated React component

Animated command palette that opens with ⌘K: a dimmed overlay, a search field that filters a list of commands, and Framer Motion enter and exit transitions. Also includes the Motion Kit Command Morph variant. Also includes Prism Command Palette, a palette that grows out of its own Command K pill, with a pane of glass and a thin prism sliding between results, a preview beside the list, and Enter folding it back into the pill with what happened.

  • Free
  • Motion Effects
  • Spring
  • Hover

Pops when it opens, ticks as the highlight moves by keyboard and taps when you run a command. Sound is off on this site until you switch it on.

Command Palette

Command Morph

Prism Command Palette

Like Command Palette? 256 more are in Pro.

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

Set it up, copy the code

Choose values for the main props and the JSX on the right updates to match.

Search field placeholder on the first page. Nested pages show "Search…".

Opt-in: Cmd/Ctrl+K anywhere on the page focuses the search field. Off by default.

Walks through the palette by itself until someone touches it.

Extra classes for the outer box.

The text in the empty search field.

Soft sounds: opening, moving, running. They also follow the site-wide sound switch.

Sound level, 0 to 1.

Plays a short demo by itself until the visitor touches it. Never runs under reduced motion.

Your JSX

<CommandPalette
  CommandMorph.placeholder="Type a command…"
  CommandMorph.hotkey={false}
  CommandMorph.autoplay={false}
  CommandMorph.className=""
  PrismCommandPalette.placeholder="Search or run a command"
  PrismCommandPalette.enableSound={true}
  PrismCommandPalette.volume={0.8}
  PrismCommandPalette.autoplay={false}
/>

Props

PropTypeDefaultWhat it does
className—Optional className for the root wrapper.
CommandMorph.commandsDEFAULT_COMMANDSCommands on the first page, each { id, label, icon, hint?, crumb?, children? }. Items with children open a nested page.
CommandMorph.placeholder"Type a command…"Search field placeholder on the first page. Nested pages show "Search…".
CommandMorph.onSelect—Called when the user runs a command without children, with the groups that led to it.
CommandMorph.hotkeyfalseOpt-in: Cmd/Ctrl+K anywhere on the page focuses the search field. Off by default.
CommandMorph.autoplayfalseWalks through the palette by itself until someone touches it.
CommandMorph.className—Extra classes for the outer box.
PrismCommandPalette.itemssample dataThe commands: { id, group, label, hint, icon?, initials?, avatar?, color, keys?, done, meta? }, where done is what the pill says after it runs.
PrismCommandPalette.onRun—Called with the command that was run.
PrismCommandPalette.placeholder"Search or run a command"The text in the empty search field.
PrismCommandPalette.enableSoundtrueSoft sounds: opening, moving, running. They also follow the site-wide sound switch.
PrismCommandPalette.volume0.8Sound level, 0 to 1.
PrismCommandPalette.autoplayfalsePlays a short demo by itself until the visitor touches it. Never runs under reduced motion.
PrismCommandPalette.className""Extra classes for the outer element.
enableSoundtruePlays interface sounds on interaction. They follow the sound switch (setSoundsEnabled, on by default) and stay silent on hover. Autoplay makes the same sounds once the visitor has used the page. Pass false to silence this component.

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/command-palette
  2. 4

    Check what was added

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

    components/
    command-palette/
    command-morph.tsx
    command-palette.tsx
    index.ts
    prism-command-palette.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 lucide-react cmdk @radix-ui/react-dialog

    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 { CommandPalette } from "@/components/command-palette";
    
    export default function Page() {
      return (
        <main>
          <CommandPalette />
        </main>
      );
    }

Like Command Palette? 256 more are in Pro.

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

About Command Palette

The Command Palette is an animated command interface triggered by the ⌘K keyboard shortcut. It opens with a Framer Motion spring animation and closes with an exit transition coordinated by AnimatePresence. Commands are grouped into navigation, action, and theme sections, and are filterable by keyboard input in real time. A backdrop blur overlay dims the page behind the palette. A production-ready implementation of the command palette pattern for keyboard-first application navigation.

Good for

  • Application and dashboard navigation
  • Developer tool command interfaces
  • Keyboard-first navigation patterns
  • Power user and productivity tool UIs

Command Palette questions

How do I install the command palette?

Run `npx shadcn@latest add @nexus-labs/command-palette`. It installs cmdk, @radix-ui/react-dialog, framer-motion and lucide-react, plus the shadcn/ui command component.

Which keyboard shortcuts does it support?

Cmd+K on macOS or Ctrl+K elsewhere toggles it, the arrow keys move through results, Enter selects, and Esc closes. The search input is focused when it opens.

How do I change the commands?

The commands live in the `COMMANDS` array at the top of the file, each with a label, description, Lucide icon, action hint and value. Selecting an item closes the palette, so add your own navigation or action logic in the item's `onSelect` handler.

Does it work with the Next.js App Router?

Yes. It is a client component (`"use client"`) that listens for the shortcut on `window`, so render it from any page or layout.

Does it make sound, and how do I turn it off?

Pops when it opens, ticks as the highlight moves by keyboard and taps when you run a command. Sounds are synthesised with the Web Audio API, so there are no audio files, and they only play after a click or key press. Pass `enableSound={false}` to silence this component, or call `setSoundsEnabled(false)` from `@/lib/ui-sounds` to switch every sound off at once. The CLI installs `@/lib/ui-sounds` with the component.