@chatwoot/jumpbar

中文文档
0.1.2发布于 2026/11/04MITTypeScriptESM + CJS零依赖近 30 天下载 2887

Lightweight command palette for Vue 3: a framework-free ranking core with fuzzy matching, sections, pages, prefixes and frecency, plus a native shell with async sources.

原始使用文档
文档目录9 节
  1. Install
  2. Any framework
  3. Styling
  4. Quick start
  5. Items
  6. Sources
  7. Ranking
  8. Keyboard
  9. Development

jumpbar

Press ⌘K, type a few letters, pick an action. jumpbar is the command palette behind the Chatwoot dashboard, packaged so any Vue 3 app can use it, and any JavaScript app can use its ranking core.

It is small: the ranking core is plain JavaScript with no dependencies (about 1 KB gzipped); the shell is a native <dialog> rendered with Tailwind utilities (about 5 KB gzipped with the core).

  • Fuzzy matching with accent folding, sections, nested pages and prefixes
  • Frecency so the things you use rise to the top
  • Sync commands sources ranked on every keystroke, async search sources with per-source debounce, minimum query length and AbortSignal
  • Keyboard and pointer handling, open/close motion, skeleton rows while remote results load, RTL and IME aware

How it fits together: your app describes what it can do through sources, plain objects with a title and a run function. jumpbar ranks them against what the user typed, and the shell draws the list. The package knows nothing about your product.

The guide walks through configuration, Vue usage, plain JavaScript usage and the full reference. This README is the short version.

Install

pnpm add @chatwoot/jumpbar

The package ships compiled ES modules with TypeScript declarations; Vue stays external. vue 3.4 or newer is needed for the shell.

Any framework

The ranking core has no framework dependency. React, Svelte, Solid or plain JavaScript projects import it from @chatwoot/jumpbar/core and render their own list:

import { rank, groupBySection, createFrecency } from '@chatwoot/jumpbar/core';

const ranked = rank(items, { text: query, scopes: ['conversation'] });
const sections = groupBySection(ranked);

The CommandBar shell and useCommandBar state are Vue 3.

Styling

The shell is built from Tailwind utilities and reads every colour from a small set of semantic tokens, so it adapts to any design system.

  1. Add the preset and scan the package so its classes are generated:

    // tailwind.config.js
    module.exports = {
      presets: [require('@chatwoot/jumpbar/tailwind')],
      content: ['./node_modules/@chatwoot/jumpbar/dist/*.js'],
    };
    

    The preset registers the jumpbar-* colours as CSS variables and the open and close keyframes.

  2. Theme it. Either import the neutral defaults and override what you like (dark values apply under a dark class on the root element):

    import '@chatwoot/jumpbar/theme.css';
    
    :root {
      --jumpbar-primary: #2781f6;
    }
    

    or skip the import and map the tokens onto your existing Tailwind colours, which also carries your dark mode along:

    theme: {
      extend: {
        colors: {
          jumpbar: {
            background: colors.surface,
            foreground: colors.text,
            primary: colors.brand,
          },
        },
      },
    },
    
    TokenUsed for
    backgroundPanel
    foregroundTitles and input text
    muted-foregroundSubtitles, section labels, breadcrumbs, badges
    subtle-foregroundPlaceholder, icons, hints, chevrons
    mutedActive row, chips, avatar fallback, skeleton rows
    subtleKey caps, lighter skeleton bar
    borderDividers and key cap outline
    ringPanel outline
    primaryActive row marker, page chip text
    primary-softPage chip background
    overlayBackdrop
    online busy offlinePresence dot
  3. Provide the icon classes i-lucide-search, i-lucide-loader-circle and i-lucide-chevron-right (for example through @egoist/tailwindcss-icons with the Lucide set). Items bring their own icon class.

Quick start

Four steps, all shown in the example below:

  1. Add the Tailwind preset and theme the tokens (see Styling above).
  2. Render <CommandBar /> once, near the root of your app, and get the shared state with useCommandBar().
  3. Register sources: commands for things you already know about, search for things you fetch while the user types.
  4. Bind your shortcut and call bar.toggle().
<script setup>
import { CommandBar, createFrecency, useCommandBar } from '@chatwoot/jumpbar';

const bar = useCommandBar();

bar.configure({
  prefixes: ['@', '#'],
  context: () => ({ scopes: ['conversation'] }),
  frecency: createFrecency({ storage: localStorage, key: 'palette-usage' }),
  onSelect: item => track(item),
  onClose: () => {},
  onError: (error, source) => report(error),
  limit: 100,
});

bar.register({
  id: 'navigation',
  commands: () => [
    {
      id: 'inbox',
      title: 'Go to inbox',
      section: 'Navigation',
      icon: 'i-lucide-inbox',
      shortcut: ['⌥', 'I'],
      run: () => router.push('/inbox'),
    },
  ],
});

bar.register({
  id: 'contacts',
  minQuery: 3,
  debounce: 300,
  when: ({ page }) => !page,
  search: async ({ text, signal }) => {
    const contacts = await api.search(text, { signal });
    return contacts.map(contact => ({
      id: `contact-${contact.id}`,
      title: contact.name,
      subtitle: contact.email,
      section: 'Contacts',
      avatar: { name: contact.name, src: contact.thumbnail },
      run: () => router.push(`/contacts/${contact.id}`),
    }));
  },
});
</script>

<template>
  <CommandBar
    placeholder="Search or jump to"
    empty-text="No matches"
    :hints="[
      { keys: ['↑', '↓'], label: 'navigate' },
      { keys: ['↵'], label: 'select' },
      { keys: ['esc'], label: 'close' },
    ]"
  />
</template>

Bind the global shortcut yourself and call bar.toggle(). bar.open({ page, query }) opens straight into a page, for example a snooze picker.

CommandBar props: placeholder, emptyText, scopeLabel (a chip before the input, for example the selected record), hints and dir (ltr or rtl).

Items

Sources return plain objects:

FieldMeaning
idUnique across all sources. Frecency and dedupe key on it.
titleRow label. Children are matched through parentTitle title too.
subtitleMuted text after the title. Takes only the space left after the breadcrumb and title.
sectionGroup header. With nothing typed, groups keep source order; with text, the best match leads.
iconCSS class rendered as the leading glyph.
avatar{ name, src, status } instead of the icon, initials as fallback; status is online, busy or offline.
badgeShort trailing text.
shortcutTrailing key labels, for example ['⌥', 'E']. Alternatives as nested lists: [['⌥', 'J'], ['⌥', 'K']].
keywordsExtra words the matcher sees (word-start matches only).
scopesRanks first when one matches context.scopes.
prefixTyping this character first lists only items carrying it.
weightStatic boost between 0 and 1.
placefirst or last: sorts around every other match, in declared order.
searchFromRootfalse keeps a child out of root searches (prefix and page only).
pageSelecting opens a page listing the items whose parent is its id.
placeholderInput placeholder while that page is open.
parentId of the page this item lives under.
runCalled with the context as the bar starts closing; the dialog leaves the top layer about 150 ms later. Rows without it are inert.

Sources

bar.register({
  id: 'conversations',
  minQuery: 2,
  debounce: 300,
  when: ({ page }) => !page,
  commands: request => [],
  search: async request => [],
});

commands runs on every keystroke and is ranked. search runs after the debounce with an AbortSignal; its results keep their own order, append after the ranked commands at the root, and replace the static children on a page. The request carries query, text, prefix, page, context and, for search, matches (how many commands matched locally) and signal. register returns a function that removes the source again. A searcher that throws has its rows dropped and onError(error, source) called; the default rethrows. Text queries show at most limit ranked commands (default 50).

Ranking

Titles match by exact, prefix, word start, every-word-starts-a-word, then scattered characters. Subtitles and keywords only match on word starts, so a long description never floods the list. Items in context.scopes get a boost, recently used items another, weight a small static one. place: 'first' and place: 'last' sit outside the scoring entirely.

Keyboard

↑ ↓ move, ⌘/Ctrl + ↑ ↓ jump to the first or last row, Enter selects, Esc closes, Backspace on an empty query goes back one page. Hover only changes the selection when the pointer really moves, so arrow keys keep working under a resting cursor.

Development

pnpm install
pnpm test
pnpm build

Source lives in src/ with specs next to it; dist/ is built on publish and is not committed. To release, bump version in package.json and run pnpm publish. The prepublishOnly script builds and runs the tests first, so a broken build never reaches the registry.

版本与发布记录

@chatwoot/jumpbar 共发布 4 个版本,首次发布于 2026/11/02;过去 12 个月发布了 4 个版本。

版本发布日期距今
0.1.2latest2026/11/045 天前
0.1.12026/11/036 天前
0.1.02026/11/026 天前
0.0.0-stage2026/11/026 天前

关于 @chatwoot/jumpbar 的常见问题

@chatwoot/jumpbar 是什么?

Lightweight command palette for Vue 3: a framework-free ranking core with fuzzy matching, sections, pages, prefixes and frecency, plus a native shell with async sources.

如何安装 @chatwoot/jumpbar?

在项目目录运行 npm install @chatwoot/jumpbar,或使用 pnpm add / yarn add / bun add。

@chatwoot/jumpbar 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@chatwoot/jumpbar 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@chatwoot/jumpbar 可以商用吗?

@chatwoot/jumpbar 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@chatwoot/jumpbar 的下载量有多少?

根据 npm 官方下载统计,@chatwoot/jumpbar 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,887 次,日均约 96 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@chatwoot/jumpbar 还在维护吗?

最新版本 0.1.2 发布于 2026/11/04(5 天前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/11/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。