Skip to main content
The Vercel example reproduces the clean, dark command menu found in the Vercel dashboard. It features a paged navigation model — pressing a shortcut or selecting an item pushes a new “page” onto a stack, and pressing Backspace on an empty input pops back. A subtle scale(0.96) bounce animation plays on Enter or when navigating between pages.

Notable implementation details

Paged navigation with a page stack. The component maintains a pages array in state. Selecting “Search Projects…” pushes 'projects' onto the stack, which causes Command.List to render the <Projects /> sub-menu instead of <Home />. Pressing Backspace on an empty input calls popPage() to go back. This pattern is framework-agnostic and requires no router.
Backspace-to-go-back guard. The onKeyDown handler only intercepts Backspace when the search input is empty (inputValue.length === 0) and the user is not already on the home page. This prevents accidental back-navigation while the user is typing a search query.
Bounce animation on confirm. When Enter is pressed (or a page transition fires), the bounce() function briefly sets transform: scale(0.96) on the root element and resets it after 100 ms using setTimeout. Because the root element has transition: transform 100ms ease, this produces a subtle physical “click” feel without any animation library.
You can extend the page stack pattern to support arbitrarily deep sub-menus — for example, pushing 'project-settings' after 'projects'. Render the correct content by switching on activePage rather than nesting Command components.