Global Command Palette (Action Bar) for React apps and as a drop‑in Web Component. Ships ESM/CJS for apps and a UMD bundle for direct browser embeds. Includes providers, a standalone palette, and a small web API for imperative control.
- React: use
CommandPaletteProvider
orActionBarRoot
- Web: load the UMD bundle and call
window.DealActionBarUMD.mount()
- Docs: see
_docs/
in this package for in-depth guides
- Features
- Installation (npm/pnpm)
- Quick Start (React)
- Quick Start (Browser UMD)
- Standalone Provider
- Commands and API
- Styling / Theming
- Build & Local Development
- Deploying the Browser Bundle
- Docs Index (internal)
- Global command palette with keyboard shortcuts (e.g., Cmd/Ctrl+K)
- Searchable actions with groups, icons, and sections
- Pluggable command sources, async suggestions, AI hooks
- React provider for context-driven actions
- Framework-agnostic Web Component via UMD for any site
pnpm add @deal-scale/action-bar
# or
npm i @deal-scale/action-bar
Wrap your app with the provider and render the root.
import React from 'react'
import { ActionBarRoot, CommandPaletteProvider } from '@deal-scale/action-bar'
export default function App() {
return (
<CommandPaletteProvider
shortcuts={[['mod', 'k']]} // Cmd/Ctrl + K
commands={[
{ id: 'open-settings', label: 'Open Settings', run: () => console.log('settings') },
{ id: 'goto-dashboard', label: 'Go to Dashboard', href: '/dashboard' },
]}
>
<ActionBarRoot />
{/* your app */}
</CommandPaletteProvider>
)
}
shortcuts
: array of key combos (e.g.,[ ['mod','k'] ]
)commands
: array of commands{ id, label, run? | href?, icon?, section? }
onOpenChange? (boolean)
: open state callbacksuggest? (query) => Promise<Command[]>
: async suggestions
The UMD build exposes a global DealActionBarUMD
.
<!-- 1) Load the bundle (local or from a CDN) -->
<script src="/dist/umd/index.js"></script>
<!-- Example CDN (once you publish to npm): -->
<!-- <script src="https://unpkg.com/@deal-scale/action-bar/dist/umd/index.js"></script> -->
<!-- 2) Mount somewhere after DOM is ready -->
<script>
const unmount = window.DealActionBarUMD.mount({
shortcuts: [['mod','k']],
commands: [
{ id: 'open-settings', label: 'Open Settings', run: () => alert('settings') },
{ id: 'help', label: 'Help Center', href: '/help' },
],
})
// Later, to clean up:
// unmount()
</script>
shortcuts
: same as Reactcommands
: same as Reactcontainer?
: HTMLElement to render into; defaults todocument.body
theme?
:{ className?: string }
for host wrapper
If you only need the provider (e.g., to wire your own UI):
import { StandaloneCommandPaletteProvider } from '@deal-scale/action-bar'
A command is a simple object:
export type Command = {
id: string
label: string
section?: string
icon?: React.ReactNode
href?: string // navigate
run?: () => void // imperative action
}
- Use
href
for navigation orrun
for side effects. - Group by
section
for visual organization. - Provide
suggest(query)
to stream or return async commands.
This package ships unstyled primitives integrated with your design system. See examples in:
components/command/CommandPalette.tsx
components/command/CommandInputTray.tsx
If you use shadcn/radix, slot our components into your tokens. For a basic look-and-feel, add a host class via provider prop theme={{ className: 'your-theme' }}
and style accordingly.
This package uses tsup
.
Scripts in package.json
:
pnpm build
— builds ESM/CJS and UMD bundlespnpm build:lib
— ESM/CJS + typespnpm build:umd
— IIFE UMD for browsers atdist/umd/index.js
pnpm i
pnpm build
You can deploy dist/umd/index.js
on any static host or CDN.
- Local hosting: copy
dist/umd/index.js
to your public directory and reference it with<script src="/dist/umd/index.js"></script>
- CDN (after publishing to npm):
- unpkg:
https://unpkg.com/@deal-scale/action-bar/dist/umd/index.js
- jsDelivr:
https://cdn.jsdelivr.net/npm/@deal-scale/action-bar/dist/umd/index.js
- unpkg:
For custom domains, serve from your site (e.g., https://www.cybershoptech.com/assets/action-bar/index.js
) and update the script tag accordingly.
This repo includes more detailed, task-focused docs under _docs/
:
_docs/embed-npm.md
— React/Next.js app integration via npm_docs/embed-script.md
— Direct<script>
embed for any website_docs/embed-with-api-key.md
— Securing usage with an API key pattern_docs/browser-extension.md
— Notes for browser extension contexts
Each doc contains copy-paste snippets and deployment tips specific to that scenario.
MIT