@eos-ui/vue

中文文档
0.20.0发布于 2026/10/28MITTypeScriptES Module构建来源已验证近 30 天下载 5488

eos: a component library for Vue.

原始使用文档

@eos-ui/vue

A component library for Vue. High contrast and consistent by default, rebrandable with a few lines.

Documentation, live examples and a theme playground

npm install @eos-ui/vue
import { createApp } from "vue";
import { createEos } from "@eos-ui/vue";
import "@eos-ui/vue/style.css"; // once, in your entry file

createApp(App)
  .use(
    createEos({
      locale: "en-CA",
      currency: "CAD",
      theme: { brand: "#2c95b4", radius: "round" },
    }),
  )
  .mount("#app");
<script setup lang="ts">
import { ref } from "vue";
import { ETextField, EButton } from "@eos-ui/vue";
const email = ref("");
</script>

<template>
  <ETextField v-model="email" label="Email" type="email" required />
  <EButton>Continue</EButton>
</template>
  • One stylesheet (about 21 kB gzipped), imported once: @eos-ui/vue/style.css is required even without the plugin. All CSS ships in that file (no per-component CSS). The JavaScript has no CSS imports, so server rendering needs no bundler setup.
  • Requirements: ESM only, Node 22 or later, Vue 3.5 or later. Tree-shaking is done by your bundler. Your bundler must replace process.env.NODE_ENV with a literal, as Vite, webpack, Rollup, esbuild and Nuxt do by default. The library reads it to keep development warnings (a theme that fails contrast) out of production builds; with a bundler that does not define it, the warnings stay on, and you can turn the contrast one off with warnOnContrast: false.
  • Fonts are opt-in: @eos-ui/vue/fonts-self-hosted.css serves the default typefaces from files in the package; @eos-ui/vue/fonts.css loads them from Google Fonts, which shares visitors' IP addresses with Google; @eos-ui/vue/fonts-fallback.css has only the metric-matched fallback faces. With none of them, the theme uses system fonts.
  • Everything sits in the cascade layers e.*, so your own CSS wins without specificity fights.
  • Plugin options: locale, currency, dir, messages, icons, theme, themeTarget, portalTarget, warnOnContrast and applyTheme (false when the page ships the theme CSS itself). Without a theme nothing is applied: style.css carries the default theme. A theme goes into the document as a stylesheet in the token layer, so your own CSS wins over it. EConfigProvider changes the theme, locale or direction for one part of the page.
  • A message can be a plural object ({ one, other } and the locale's other categories) when it takes a count n. resultsCount, rows, rowsAnnounce and rangeDone do.
  • defineTheme() (re-exported from @eos-ui/tokens) builds a theme from brand, accent and other inputs and checks its contrast.
  • Icons: a built-in Phosphor set, or Lucide, Tabler, Heroicons, Phosphor (Vue), Iconify or your own set (@eos-ui/vue/icons, see Bring your own icons).
  • Per-component paths: @eos-ui/vue/components/EButton (any component), and @eos-ui/vue/plugin for createEos and themeCss. They leave out the built-in icon set, which the package root registers; import "@eos-ui/vue/icons/builtin" brings it back.
  • EosResolver from @eos-ui/vue/resolver auto-imports components for unplugin-vue-components. It does not import the stylesheet unless you pass { css: true }.
  • Importing the package types $e (the config) in templates. createEos() registers no components, so their global types are opt-in: after app.component("EButton", EButton), add import type {} from "@eos-ui/vue/globals" (or "types": ["@eos-ui/vue/globals"] in tsconfig.json). With unplugin-vue-components you do not need it: the plugin writes its own components.d.ts.
  • Composables for common needs: useAnnouncer (screen reader announcements), useShortcuts (keyboard shortcuts), useCopy, useToast. See Composables.
  • @eos-ui/vue/llms.txt and llms-full.txt give AI coding assistants an index and the complete docs.
  • Components work without the plugin, in English and US dollars.

Nuxt

Import the stylesheet in nuxt.config.ts, install the plugin in a Nuxt plugin, and put the theme into the server-rendered <head> with themeCss(). createEos touches the document only in a browser: with a theme it adds the theme as a stylesheet once the app is installed, so without the <style> the first paint is unthemed.

// nuxt.config.ts
export default defineNuxtConfig({ css: ["@eos-ui/vue/style.css"] });
// plugins/eos.ts
import { createEos, defineTheme, themeCss } from "@eos-ui/vue";

const theme = defineTheme({ brand: "#2c95b4", radius: "round" });

export default defineNuxtPlugin((nuxtApp) => {
  // The <style> below carries the theme on the server and in the browser, so the plugin adds no second copy.
  nuxtApp.vueApp.use(createEos({ locale: "en-CA", currency: "CAD", theme, applyTheme: false }));
  useHead({
    style: [{ id: "eos-theme", innerHTML: themeCss(theme) }],
    htmlAttrs: { lang: "en-CA", dir: "ltr" },
  });
});

Components render on the server without a document. Build the theme once with defineTheme and give the same one to createEos and themeCss, so the server and the browser agree. applyTheme: false is not required: without it the browser also gets the plugin's own copy of the theme, scoped to :root[data-e-theme], which is the same tokens again. The plugin sets lang and dir on <html> only in a browser, so set them for the server with htmlAttrs.

Source, issues and contributing. MIT licensed.

版本与发布记录

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

版本发布日期距今
0.20.0latest2026/10/2816 天前
0.19.02026/10/2816 天前
0.18.02026/10/2619 天前
0.17.12026/10/2519 天前
0.17.02026/10/2519 天前
0.16.02026/10/2519 天前

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

@eos-ui/vue 是什么?

eos: a component library for Vue.

如何安装 @eos-ui/vue?

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

@eos-ui/vue 支持 TypeScript 吗?

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

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

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

@eos-ui/vue 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

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

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

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

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

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

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