{"id":18592592,"url":"https://github.com/bytebase/vue-kbar","last_synced_at":"2025-08-22T00:31:47.498Z","repository":{"id":37916570,"uuid":"434124962","full_name":"bytebase/vue-kbar","owner":"bytebase","description":"Extensible command+k interface for Vue 3 applications. Inspired by timc1/kbar.","archived":false,"fork":false,"pushed_at":"2023-10-07T06:14:30.000Z","size":513,"stargazers_count":65,"open_issues_count":5,"forks_count":8,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-12-18T02:16:46.200Z","etag":null,"topics":["command-palette","commandbar","javascript","kbar","shortcuts","typescript","vue"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bytebase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-02T07:35:27.000Z","updated_at":"2024-08-28T15:17:45.000Z","dependencies_parsed_at":"2024-06-19T23:14:16.492Z","dependency_job_id":"e3b94f15-439e-4a2e-ab95-f89ed09f90e8","html_url":"https://github.com/bytebase/vue-kbar","commit_stats":{"total_commits":67,"total_committers":6,"mean_commits":"11.166666666666666","dds":"0.14925373134328357","last_synced_commit":"599e5993cd3c01de91d96d252771ca97fc7aab9c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytebase%2Fvue-kbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytebase%2Fvue-kbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytebase%2Fvue-kbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytebase%2Fvue-kbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bytebase","download_url":"https://codeload.github.com/bytebase/vue-kbar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230542288,"owners_count":18242332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-palette","commandbar","javascript","kbar","shortcuts","typescript","vue"],"created_at":"2024-11-07T01:09:09.824Z","updated_at":"2024-12-20T06:06:55.758Z","avatar_url":"https://github.com/bytebase.png","language":"TypeScript","readme":"# vue-kbar\n\nExtensible command+k interface for Vue 3 applications. Inspired by [timc1/kbar](https://github.com/timc1/kbar).\n\n\u003e Caution! This is still WIP.\n\n## Screenshots\n\n\u003e TBD\n\n## How to use\n\n### 1. Install dependency\n\n```bash\n# npm install --save @bytebase/vue-kbar\n```\n\nor if you are using yarn\n\n```bash\n# yarn add @bytebase/vue-kbar\n```\n\n### 2. Import core components\n\n```typescript\n// App.vue\n\nimport {\n  KBarProvider,\n  KBarPortal,\n  KBarPositioner,\n  KBarAnimator,\n  KBarSearch,\n  createAction,\n} from \"@bytebase/vue-kbar\";\n```\n\n### 3. Define global actions\n\n```typescript\n// App.vue\n\n// use `createAction` as a type definition helper\nconst globalActions = [\n  createAction({\n    id: \"home\",\n    name: \"Home\",\n    shortcut: [\"g\", \"h\"],\n    section: \"Navigation\",\n    subtitle: \"Go back to home\",\n    perform: () =\u003e router.push(\"/\"),\n  }),\n  createAction({\n    id: \"docs\",\n    name: \"Docs\",\n    shortcut: [\"g\", \"d\"],\n    section: \"Navigation\",\n    perform: () =\u003e router.push(\"/docs\"),\n  }),\n];\n```\n\n### 4. Use core components\n\nYou need to wrap your Vue app entrance by vue-kbar core components.\n\nvue-kbar comes with no out-of-the-box styles. You may specify styles according to your application's UI design. Here is an example of using tailwindcss.\n\n```html\n\u003cKBarProvider :actions=\"globalActions\"\u003e\n  \u003cKBarPortal\u003e\n    \u003cKBarPositioner class=\"bg-gray-300 bg-opacity-80\"\u003e\n      \u003cKBarAnimator\n        class=\"bg-white shadow-lg rounded-lg w-128 overflow-hidden divide-y\"\n      \u003e\n        \u003cKBarSearch\n          class=\"px-3 py-4 text-lg w-full box-border outline-none border-none\"\n        /\u003e\n        \u003cMyResultsRenderer /\u003e\n        \u003c!-- see below --\u003e\n      \u003c/KBarAnimator\u003e\n    \u003c/KBarPositioner\u003e\n  \u003c/KBarPortal\u003e\n\n  \u003c!-- you application entrance here --\u003e\n  \u003cMyApp /\u003e\n\u003c/KBarProvider\u003e\n```\n\n### 5. Implement a results renderer\n\nvue-kbar doesn't render results it self. You may render results with your components and styles.\n\nHere is a simple example of how to implement `\u003cMyResultsRenderer /\u003e` above.\n\n```html\n// MyResultsRenderer.vue\n\n\u003cKBarResults\n  :items=\"matches.results\"\n  :item-height=\"itemHeight\"\n  class=\"max-h-96\"\n\u003e\n  \u003c!-- KBarResults creates a virtual list to manage mass of actions --\u003e\n  \u003c!-- It also reacts to up/down/enter keystroke for activeIndex management --\u003e\n  \u003c!-- You still may use your own component if you really want to customize the result list --\u003e\n  \u003ctemplate #item=\"{ item, index, active }\"\u003e\n    \u003cdiv v-if=\"typeof item === 'string'\" class=\"section\"\u003e\n      \u003c!-- string items are section headers --\u003e\n      \u003c!-- now we just render them as plain texts --\u003e\n      {{ item }}\n    \u003c/div\u003e\n    \u003cdiv v-else class=\"item\" :class=\"{ active }\"\u003e\n      \u003c!-- render featured actions --\u003e\n      \u003cdiv class=\"main\"\u003e{{ item.name }}\u003c/div\u003e\n      \u003cspan v-if=\"item.subtitle\" class=\"subtitle\"\u003e {{ item.subtitle }} \u003c/span\u003e\n    \u003c/div\u003e\n  \u003c/template\u003e\n\u003c/KBarResults\u003e\n```\n\n```typescript\n// MyResultsRenderer.vue\n\nimport { useKBarMatches, KBarResults } from \"@bytebase/vue-kbar\";\n\nexport default {\n  name: \"MyResultsRenderer\",\n  components: { KBarResults },\n  setup() {\n    // Visit the latest matches\n    const matches = useKBarMatches();\n\n    // Tell KBarResults the height of each item will be rendered\n    const itemHeight = (params: { item: any; index: number }) =\u003e {\n      if (typeof params.item === \"string\") return 32;\n      return 64;\n    };\n\n    return { matches, itemHeight };\n  },\n};\n```\n\n### 6. Register actions dynamically\n\nYou may register actions dynamically by calling `useRegisterActions` in any descendant component of `\u003cKBarProvider\u003e`. This hook method is reactive and bound to the component's life cycle, so you don't need to refresh or unregister manually. Here is an example.\n\n```typescript\n// SomeComponent.vue\n\nimport { useRegisterActions, createAction } from \"@bytebase/vue-kbar\";\n\nexport default {\n  name: \"SomeComponent\",\n  setup() {\n    // Maybe you've already used some auto-fetch stuff to\n    // update the `posts` automatically\n    const posts = useFetch(\"/your-api\", [deps]);\n\n    // Mapping posts to actions as a computed\n    const actions = computed(() =\u003e\n      posts.map((post) =\u003e\n        createAction({\n          id: `to-detail-${post.id}`,\n          name: post.title,\n          subtitle: post.abstract,\n          section: \"Posts\",\n          perform: () =\u003e router.push(`/post/${post.id}`),\n        })\n      )\n    );\n\n    // Dynamically register actions\n    // pass `prepend: true` to make them listed before global actions\n    // When `actions` changed, they will be automatically re-registered\n    useRegisterActions(actions, true);\n  },\n};\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytebase%2Fvue-kbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytebase%2Fvue-kbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytebase%2Fvue-kbar/lists"}