Build a keyboard-first command palette in React: a modal search surface that opens from a trigger or platform shortcut, fuzzily filters commands, supports wrapped arrow navigation, and exposes its active option to assistive technology.
Implement the App component in App.tsx. It receives no props. Keep the provided six-command data set and visual shell.
⌘K on macOS, or pressing Ctrl+K elsewhere opens a labelled modal dialog, clears the previous query, selects the first command, and focuses the search field.se keeps Open Settings and Search Docs in source order. Typing nf still finds New File because fuzzy matching accepts ordered, non-adjacent characters.ArrowUp from the first wraps to the last and ArrowDown wraps back. Enter runs the active command.Enter closes the palette and changes the live status to Ran: <label>.Escape, a backdrop click, or the same global shortcut closes without changing the status. Focus returns to the trigger.activeIndex to 0 after every query change. If there are no matches, arrows and Enter do nothing and the palette shows No commands found.dialog; the input is a combobox controlling a listbox. Give every option a stable id, set aria-selected, point aria-activedescendant at the active option, and keep Tab on the only focusable control while the modal is open.open mounts the dialog, and return focus to the trigger when the palette closes.filtered during render from query; do not store results in state.The full solution is part of Premium
Walkthrough, edge cases, complexity notes, and the runnable editor unlock with a Premium subscription.
Submissions are part of Premium
Unlock community code, comments, reactions, and framework-specific approaches.
Build a keyboard-first command palette in React: a modal search surface that opens from a trigger or platform shortcut, fuzzily filters commands, supports wrapped arrow navigation, and exposes its active option to assistive technology.
Implement the App component in App.tsx. It receives no props. Keep the provided six-command data set and visual shell.
⌘K on macOS, or pressing Ctrl+K elsewhere opens a labelled modal dialog, clears the previous query, selects the first command, and focuses the search field.se keeps Open Settings and Search Docs in source order. Typing nf still finds New File because fuzzy matching accepts ordered, non-adjacent characters.ArrowUp from the first wraps to the last and ArrowDown wraps back. Enter runs the active command.Enter closes the palette and changes the live status to Ran: <label>.Escape, a backdrop click, or the same global shortcut closes without changing the status. Focus returns to the trigger.activeIndex to 0 after every query change. If there are no matches, arrows and Enter do nothing and the palette shows No commands found.dialog; the input is a combobox controlling a listbox. Give every option a stable id, set aria-selected, point aria-activedescendant at the active option, and keep Tab on the only focusable control while the modal is open.open mounts the dialog, and return focus to the trigger when the palette closes.filtered during render from query; do not store results in state.The full solution is part of Premium
Walkthrough, edge cases, complexity notes, and the runnable editor unlock with a Premium subscription.
Submissions are part of Premium
Unlock community code, comments, reactions, and framework-specific approaches.
Unlock the solution & editor
Runnable editor + tests
Solve in the browser with instant Jest feedback.
Detailed solutions
Walkthroughs, edge cases, and complexity notes.
Multi-framework variants
React, Vue, Vanilla, Angular — same question, different stacks.