@chai-ui/vue

中文文档
1.4.1发布于 2026/10/31MITTypeScriptES Module构建来源已验证近 30 天下载 3723

Chai UI Vue components — smart, drop-in UI for AI apps: Composer, Media Analyzer, Result Card, Edit Card, Side Panel, and the useComposer composable.

原始使用文档
文档目录8 节
  1. Install
  2. Your own font
  3. Dark theme
  4. Quick start
  5. The Vue names
  6. What's in the package
  7. Your API keys stay on your server
  8. Without a server route

Chai UI

npm version MIT license CI Coverage Docs

@chai-ui/vue

Chai UI for Vue: drop-in components for the input and output surfaces of generative-media apps: a prompt composer, a media-to-prompt analyzer, a result card and an edit card, with the AI work built in and wired to Fal.ai, OpenRouter, Vercel AI Gateway or your own engine. Everything is controlled: you own the state with v-model, and the components render it.

These are the same components as @chai-ui/react and @chai-ui/svelte, with the same behavior. All three are thin layers over @chai-ui/core and run one shared test suite, including the WCAG 2.2 AA checks (axe, keyboard and focus).

Building with it, or pointing a coding agent at it? Read DESIGN.md (shipped in the package) for the usage rules, and the docs site's llms.txt for the API. The code boxes on chai-ui.com/docs switch between React, Vue and Svelte.

Install

pnpm add @chai-ui/vue @chai-ui/core @chai-ui/tokens

Vue 3.5 or later, Nuxt included. No Chai-specific build setup.

// main.ts: tokens first, then the component styles that read them
import "@chai-ui/tokens/css";
import "@chai-ui/vue/style.css";

Your own font

style.css loads Roboto, Material Design 3's typeface. If your app has its own font, import @chai-ui/vue/style-without-fonts.css in its place (the same styles, without Roboto) and point the components at your font:

:root { --chai-type-family-material: "Your Font", system-ui, sans-serif; }

Dark theme

The components have a dark theme. It's opt-in: set data-chai-theme="dark" on <html>, or on any element, and every component inside it switches.

<html data-chai-theme="dark">

Chai doesn't follow the system setting on its own, because your app decides its theme. Following it, overriding a single color, and the dark values themselves are in the @chai-ui/tokens README.

Quick start

<!-- App.vue -->
<template>
  <ChaiProvider><Create /></ChaiProvider>
</template>

<!-- Create.vue -->
<script setup lang="ts">
import { computed, ref } from "vue";
import { Composer, ResultCard, createFalEngine, useComposer } from "@chai-ui/vue";

const engine = createFalEngine();
const value = ref("");
const { run, submit, cancel, enhance, enhancing } = useComposer({ engine });
const busy = computed(() => run.value?.results.some((r) => r.status === "queued" || r.status === "running") ?? false);

async function onEnhance(prompt: string) {
  value.value = await enhance.value!(prompt);
}
</script>

<template>
  <Composer v-model="value" :submitting="busy" :enhancing="enhancing" @submit="submit" @abort="cancel" @enhance="onEnhance" />
  <ResultCard v-if="run" :results="run.results" :prompt="run.request.prompt" @action="() => {}" />
</template>

To try it before setting up a provider, leave out engine and ChaiProvider: everything then runs on built-in mocks, with no network calls and no keys.

The Vue names

The props are React's, with Vue's conventions:

ReactVue
value + onChangev-model
x + onXChangev-model:x, e.g. v-model:attachments, v-model:model-id, v-model:regions
onSubmit, onAction, onEnhance, onAbort@submit, @action, @enhance, @abort
useComposer / useMediaAnalyzer hookscomposables returning refs; pass a getter for options that change
<EditCard {...edit} />edit's fields one by one, with @update:active-version and @update:regions
SidePanel's open + onOpenChange, logo and footerv-model:open, and the #logo and #footer slots (footer also takes text)
A Composer chip or menu item's iconA component

Some controls show only with a listener, as in React: the optimize button with @enhance, stop with @abort, the Model menu with @update:model-id.

Docked the bar? Set menu-placement="above" for a bar fixed to the bottom of the screen, or "below" for one fixed to the top, so every menu opens into the page. Left out, it's "auto": each menu goes where it fits.

What's in the package

  • Composer: prompt, attachments, use cases, model and aspect-ratio menus with suggested models, prompt optimization, auto-select routing, stop and retry.
  • MediaAnalyzer + useMediaAnalyzer: media in, a generation-ready prompt out.
  • ResultCard: one prompt's results, paged, with votes, retry, download, share, details, streaming text and quality-check tags (from your backend, or the opt-in judge: useComposer({ judgeModel, judgeChecks })).
  • Analytics: @event on every component reports what the person does and sees, one ChaiEvent each, for any analytics tool: @event="(e) => posthog.capture(e.name, e.properties)".
  • EditCard: marked regions with their own instructions, and each edit as a new version.
  • SidePanel: a panel beside your page with a Composer and its answers, for questions about the page (opt-in page-context, shown as a removable chip) or anything else, with prompt tips, push or overlay, and either side. Same props as React's, with v-model:open; #logo and #footer slots. See the React README's "A side panel" for the details.
  • useComposer, ChaiProvider, and the Toggle, SearchMenu and Pagination building blocks.
  • The engines and types from @chai-ui/core, re-exported.

Your API keys stay on your server

The engines call one route on your server, which adds the key. In Nuxt:

// server/api/chai/[...path].ts
import { createChaiHandler } from "@chai-ui/core/server";

const chai = createChaiHandler();
export default defineEventHandler((event) => chai.handle(toWebRequest(event)));

Then set FAL_KEY, OPENROUTER_API_KEY or AI_GATEWAY_API_KEY on your server. Other servers, and authorize and allowedModels for production, are in the @chai-ui/core README.

Without a server route

In a desktop app (Tauri, Electron) with no server route, write an engine that hands each run to your app's backend. Pass it to useComposer({ engine: desktopEngine }) and to <ChaiProvider :reasoning-engine="desktopEngine">. The @chai-ui/core README has a Tauri example, voice input, and what Stop does there.

版本与发布记录

@chai-ui/vue 共发布 24 个版本,首次发布于 2026/10/10;过去 12 个月发布了 24 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.4.1latest2026/10/319 天前
1.4.02026/10/319 天前
1.3.02026/10/319 天前
1.2.02026/10/3010 天前
1.1.22026/10/2812 天前
1.1.12026/10/2713 天前

关于 @chai-ui/vue 的常见问题

@chai-ui/vue 是什么?

Chai UI Vue components — smart, drop-in UI for AI apps: Composer, Media Analyzer, Result Card, Edit Card, Side Panel, and the useComposer composable.

如何安装 @chai-ui/vue?

在项目目录运行 npm install @chai-ui/vue,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(^3.5.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@chai-ui/vue 支持 TypeScript 吗?

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

@chai-ui/vue 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@chai-ui/vue 可以商用吗?

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

@chai-ui/vue 的下载量有多少?

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

@chai-ui/vue 还在维护吗?

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