ngx-cmdk
v0.1.0
Published
A Cmd/Ctrl+K style command palette for Angular, with search providers, favourites, recent searches, and translatable labels.
Maintainers
Readme
ngx-cmdk
A Cmd/Ctrl+K style command palette for Angular. Any component, directive, guard, or service anywhere in your app can register commands via dependency injection — no single root location required.
Install
npm install ngx-cmdkQuick start
// app.config.ts
providers: [provideCmdk()]<!-- app.html, mounted once -->
<ngx-cmdk-palette />// anywhere in your app
constructor() {
const registry = inject(CommandRegistryService);
registry.register({
label: 'Go to Settings',
shortcut: 'mod+s',
execute: () => { this.router.navigate(['/settings']); },
});
}Search providers are a second registration surface — attach an async data source and typing fans the query out to every registered provider, merging the results into the palette:
constructor() {
const search = inject(SearchRegistryService);
search.register({
key: 'fruits',
label: 'fruits',
search: async (query) => fetchResults(query),
});
}See the live docs for the full guide and API reference.
Development
This is an Angular CLI workspace with two projects: projects/ngx-cmdk (the
library) and projects/demo (a demo app that also serves as the docs site).
npx ng build ngx-cmdk # build the library first — the demo app needs it
npx ng serve demo # then serve the demo/docs app locally
npx ng test ngx-cmdk # run the library's unit testsPublishing a release
- Bump
versioninprojects/ngx-cmdk/package.json. - Cut a GitHub Release at that
version —
.github/workflows/publish-npm.ymlbuilds and publishes to npm automatically via npm's Trusted Publisher (OIDC), no token required.
License
MIT
