Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsMay 25, 2026·3 min de lectura

cmdk — Fast Unstyled Command Menu for React

A fast, composable, unstyled command menu React component used by Vercel, Linear, and Raycast for building accessible command palettes with search filtering.

Listo para agents

Copia una ruta de instalación lista para el agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
cmdk Overview
Comando de instalación directa
npx -y tokrepo@latest install 63514f0d-5857-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

Introduction

cmdk is a fast, composable, unstyled command menu component for React. It provides the behavior and accessibility for command palette UIs (the Cmd+K pattern) while leaving all visual styling to you. It powers the command menus in Vercel and other well-known products.

What cmdk Does

  • Renders a searchable command list with built-in input filtering
  • Groups items with headings and separators for organized menus
  • Supports nested pages for multi-level command navigation
  • Wraps content in an accessible dialog when using Command.Dialog
  • Provides controlled and uncontrolled modes for value and search state

Architecture Overview

cmdk uses React 18 hooks (useId, useSyncExternalStore) to manage an internal store that tracks items, groups, and filtered results. Filtering runs synchronously on each keystroke using a built-in scoring function, though a custom filter can be provided. The component renders a flat list (no virtualization) which performs well up to 2,000-3,000 items.

Self-Hosting & Configuration

  • Install via npm: npm install cmdk
  • Requires React 18 or later
  • Wrap in Command.Dialog for a modal command palette with overlay
  • Provide a custom filter prop to override the default fuzzy matching
  • Style using the [cmdk-*] CSS selectors exposed on each element

Key Features

  • Zero default styles allowing full design control via CSS selectors
  • Built-in fuzzy search filtering with customizable scoring
  • Accessible with ARIA attributes, keyboard navigation, and screen reader support
  • Composable API with Command.Group, Command.Separator, and Command.Empty
  • Lightweight with no external dependencies beyond React

Comparison with Similar Tools

  • kbar — similar command palette for React; includes its own action registration system and styling
  • ninja-keys — web component-based command palette; framework-agnostic but less React-native
  • Spotlight (Mantine) — integrated into Mantine UI; coupled to that design system
  • Headless UI Command — Tailwind Labs accessibility primitives; different composition model
  • Raycast Extensions API — native macOS command palette; not a web component

FAQ

Q: How do I open the menu with a keyboard shortcut? A: Use Command.Dialog and listen for Cmd+K (or Ctrl+K) in a useEffect to toggle the dialog open state.

Q: Can I use it outside of React? A: cmdk is React-specific. For Vue or Svelte, community ports exist, or consider framework-agnostic alternatives like ninja-keys.

Q: Does it support virtualized lists for large datasets? A: No built-in virtualization. Performance is good up to a few thousand items. For larger lists, pair it with a virtualization library.

Q: How do I add icons to command items? A: Place any element (SVG, image, icon component) inside Command.Item as a child alongside the label text.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados