# kmenu

> The perfect ⌘K menu

Latest version **2.0.4** (published 2026-09-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install kmenu
pnpm add kmenu
yarn add kmenu
bun add kmenu
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2026-09-14 |
| First published | 2022-07-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 161.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 835 |
| Author | Harsh Singh |
| Maintainers | dev-harsh |
| Keywords | kmenu, kbar, cmdk, react-cmdk, commandbar, command bar, command menu, command palette, command, palette, menu, headless, accessible, a11y, keyboard, navigation, search |

## Links

- npm: https://www.npmjs.com/package/kmenu
- Repository: https://github.com/haaarshsingh/kmenu
- Homepage: https://kmenu.dev
- npm.io page: https://npm.io/package/kmenu

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 2.0.4 (latest) — 2026-09-14
- 2.0.3 — 2025-08-15
- 2.0.2 — 2025-08-15
- 2.0.1 — 2025-08-15
- 2.0.0 — 2024-06-18
- 2.0.0-1-dev — 2024-06-18
- 2.0.0-dev — 2024-06-18
- 2.0.0-beta — 2024-06-18
- 1.4.32 — 2023-08-09
- 1.4.31 — 2023-08-09
- 1.4.3 — 2023-08-09
- 1.4.2 — 2023-07-12
- 1.4.11-beta — 2023-06-24
- 1.4.1-beta — 2023-06-24
- 1.4.0-beta — 2023-06-24
- … 38 more at https://npm.io/package/kmenu/versions

## README

![image](https://kmenu.dev/og.png)

# kmenu [![kmenu minzip package size](https://img.shields.io/bundlephobia/minzip/kmenu)](https://www.npmjs.com/package/kmenu?activeTab=code) [![kmenu package version](https://img.shields.io/npm/v/kmenu.svg?colorB=green)](https://www.npmjs.com/package/kmenu)

A lightweight command menu library that supercharges your web app's navigation and feature discoverability. It's framework-agnostic, headless, composable, <6kB, and has no runtime dependencies.

### Installation

```bash
npm install kmenu
```

### Usage

```typescript
import { CommandCore } from "kmenu";

const command = new CommandCore({
  onSelect: (option) => {
    console.log("Selected:", option);
  },
});

// Register options
command.registerOptions([
  { id: "1", label: "Home", keywords: ["main"] },
  { id: "2", label: "Search", keywords: ["find"] },
  { id: "3", label: "Settings" },
]);

// Open/close
command.open();
command.close();
command.toggle();

// Navigate
command.navigateDown();
command.navigateUp();
command.selectActive();

// Get DOM props
const inputProps = command.getInputProps();
const listProps = command.getListboxProps();
const optionProps = command.getOptionProps("1");

// Cleanup
command.destroy();
```

### API Reference

#### CommandCore

```typescript
interface CommandCore<T = any> {
  open(): void;
  close(): void;
  toggle(): void;
  setInput(value: string): void;
  registerOptions(options: CommandOption<T>[]): void;
  setActiveByIndex(index: number): void;
  navigateUp(): void;
  navigateDown(): void;
  selectActive(): void;
  on(event: EventType, handler: EventHandler): Unsubscribe;
  getState(): CommandState<T>;
  destroy(): void;
}
```

#### CommandOption

```typescript
interface CommandOption<T = any> {
  id: string;
  label: string;
  keywords?: string[];
  disabled?: boolean;
  group?: string;
  data?: T;
}
```

### Keyboard Shortcuts

- `Cmd/Ctrl + K` - Open menu
- `↑` / `↓` - Navigate options
- `Enter` - Select option
- `Escape` - Close menu

### Filters

```typescript
import { fuzzyFilter, simpleFilter } from "kmenu";

// Use built-in filters
const command = new CommandCore({
  filter: fuzzyFilter,
});

// Or create custom filter
const customFilter = (options, query) => {
  return options.filter((opt) =>
    opt.label.toLowerCase().includes(query.toLowerCase())
  );
};
```

---
_Source: https://npm.io/package/kmenu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
