npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@input-kit/command

v0.1.0

Published

Command palette

Readme

@input-kit/command

Headless command palette component and hooks for React — fuzzy search, keyboard navigation, grouped commands, and a global Cmd/Ctrl+K shortcut out of the box.

Installation

npm install @input-kit/command

Quick Start

import { CommandPalette, useCommandPalette } from '@input-kit/command';
import { useState } from 'react';

const commands = [
  {
    id: 'docs',
    label: 'Search Docs',
    group: 'Suggestions',
    shortcut: '⌘S',
    onSelect: () => window.open('/docs'),
  },
  {
    id: 'settings',
    label: 'Settings',
    group: 'Account',
    shortcut: '⌘,',
    onSelect: () => router.push('/settings'),
  },
];

function App() {
  const [open, setOpen] = useState(false);

  return (
    <>
      <button onClick={() => setOpen(true)}>Open palette</button>
      <CommandPalette
        commands={commands}
        isOpen={open}
        onClose={() => setOpen(false)}
      />
    </>
  );
}

The global Cmd/Ctrl+K shortcut is registered automatically by useCommandPalette.

API Reference

CommandPalette component

Pre-built palette UI rendered into a portal at document.body.

| Prop | Type | Default | Description | |------|------|---------|-------------| | commands | Command[] | — | Commands to display (required) | | isOpen | boolean | — | Controls visibility (required) | | onClose | () => void | — | Called when the palette should close (required) | | placeholder | string | 'Type a command or search...' | Input placeholder | | emptyMessage | string | 'No results found.' | Message when no commands match | | className | string | — | Extra CSS class on the backdrop wrapper | | style | CSSProperties | — | Inline styles on the backdrop wrapper |


useCommandPalette hook

Headless hook for custom palette UIs.

import { useCommandPalette } from '@input-kit/command';

function CustomPalette({ commands }) {
  const {
    isOpen, open, close, toggle,
    query, setQuery,
    filteredCommands,
    selectedIndex,
    selectNext, selectPrevious,
    executeSelected,
    handleKeyDown,
  } = useCommandPalette({ commands, onSelect: (cmd) => console.log(cmd) });

  if (!isOpen) return null;

  return (
    <div>
      <input value={query} onChange={e => setQuery(e.target.value)} onKeyDown={handleKeyDown} />
      <ul>
        {filteredCommands.map((cmd, i) => (
          <li key={cmd.id} aria-selected={i === selectedIndex} onClick={() => { cmd.onSelect(); close(); }}>
            {cmd.label}
          </li>
        ))}
      </ul>
    </div>
  );
}

Options

| Option | Type | Description | |--------|------|-------------| | commands | Command[] | Commands to search through | | onSelect | (command: Command) => void | Called after a command executes |

Returns

| Property | Type | Description | |----------|------|-------------| | isOpen | boolean | Whether the palette is open | | open | () => void | Open the palette | | close | () => void | Close the palette and reset query | | toggle | () => void | Toggle open/closed | | query | string | Current search query | | setQuery | (q: string) => void | Update search query | | filteredCommands | Command[] | Commands matching the current query | | selectedIndex | number | Index of the highlighted command | | setSelectedIndex | (i: number) => void | Set highlighted index | | selectNext | () => void | Move highlight down | | selectPrevious | () => void | Move highlight up | | executeSelected | () => void | Run the highlighted command | | handleKeyDown | (e: KeyboardEvent) => void | Spread onto your input element |


CommandProvider + useRegisterCommand

Register commands from anywhere in the tree without prop-drilling.

import { CommandProvider, useRegisterCommand, useCommandPalette } from '@input-kit/command';
import { useMemo } from 'react';

// Wrap your app
function App() {
  return (
    <CommandProvider>
      <Main />
    </CommandProvider>
  );
}

// Register a command from a nested component
function SaveButton() {
  // Memoize the command object to avoid re-registration on every render.
  const command = useMemo(() => ({
    id: 'save',
    label: 'Save',
    shortcut: '⌘S',
    onSelect: () => handleSave(),
  }), []);

  useRegisterCommand(command);
  return <button>Save</button>;
}

useCommands() — returns { commands, registerCommand, unregisterCommand } from the nearest CommandProvider.


Command type

interface Command {
  id: string;
  label: string;
  description?: string;
  icon?: ReactNode;
  shortcut?: string;
  group?: string;
  keywords?: string[];    // Extra words matched by fuzzy search
  disabled?: boolean;
  onSelect: () => void;
}

Keyboard shortcuts

| Key | Action | |-----|--------| | Cmd/Ctrl + K | Open palette (global, registered automatically) | | ArrowDown | Move selection down | | ArrowUp | Move selection up | | Enter | Execute selected command | | Escape | Close palette / clear input |

Search

Commands are filtered using a fuzzy match across label, description, and keywords. Query characters must appear in order but need not be consecutive.

Peer dependencies

  • react ^18 or ^19
  • react-dom ^18 or ^19

License

MIT © Input Kit