Skip to content

About

🐝 ⌘K command bar web component

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

Β 

History

83 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Command Bar 🐝

⌘K command bar web component

  • πŸš€ Fast, efficient, keyboard-driven UX
  • 🍦 Vanilla JS, native web component that works everywhere
  • 😌 Opinionated: it doesn't do much, but what it does is very easy to use
  • πŸ‘Œ Fully typed and tested

Installation

From a CDN:

import { CommandBar } from "https://esm.sh/gh/andreasphil/command-bar@<tag>";

With a package manager:

pnpm install github:andreasphil/command-bar#<tag>

Usage

Note

The component currently relies on styles from my CSS framework.

Import the component and define it:

import { CommandBar } from "@andreasphil/command-bar";

CommandBar.define();

After that, the component is available in HTML:

<command-bar></command-bar>

If a command bar is present in the DOM, you can access it globally via CommandBar.instance. This gives you methods for registering and removing commands, as well as opening the bar manually:

import { CommandBar } from "@andreasphil/command-bar";

// The method for registering commands returns a cleanup function. Use it to
// remove commands that only specific components or views need when the user
// navigates away from them.
let cleanup;

cleanup = CommandBar.instance.registerCommand({
  id: "a_command",
  name: "A command",
  // See the Command type for all available options
});

You can also open the command bar via Invoker Commands:

<command-bar id="cmd"></command-bar>

<button commandfor="cmd" command="--open">Open</button>

API

See commandBar.d.ts.

Development

Tools: Node βˆ™ pnpm βˆ™ Node's test runner βˆ™ Vite

node --run dev          # start the dev server
node --run test         # run tests
node --run test:watch   # run tests in watch mode
node --run build        # typecheck, emit declarations, and bundle

Credits

Thanks πŸ™

About

🐝 ⌘K command bar web component

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages