@fanvue/ui

中文文档
3.50.0发布于 2026/11/12Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 4546

React component library built with Tailwind CSS for Fanvue ecosystem

原始使用文档
文档目录19 节
  1. Features
  2. Setup
  3. 1. Install
  4. 2. Peer dependencies
  5. 3. Configure CSS
  6. 4. Load Inter font
  7. Usage
  8. Animated icons
  9. Theming
  10. Development
  11. Prerequisites
  12. Installation
  13. Scripts
  14. Live-reloading into pandora/eden
  15. Figma + Storybook Integration
  16. Commit Convention
  17. Contributing
  18. Security
  19. License

@fanvue/ui

React component library built with Tailwind CSS for the Fanvue ecosystem.

CI Chromatic npm version npm downloads bundle size License TypeScript Storybook Showcase GitHub

Features

  • 🎨 Tailwind CSS v4 - Modern CSS-first theming with design tokens
  • ♿ Accessible - WCAG 2.1 AA compliant with Radix UI primitives
  • 📦 Tree-shakable - Import only what you use
  • 🌙 Dark mode - Built-in light/dark theme support
  • 📝 TypeScript - Full type definitions included
  • 🧪 Tested - Unit tests with Vitest, E2E with Playwright

Setup

1. Install

npm i @fanvue/ui

2. Peer dependencies

# Required
npm i react react-dom tailwindcss

# Only if using DatePicker
npm i react-day-picker

# Only if using animated icons
npm i motion

3. Configure CSS

Add the following to your CSS entry point (e.g. app.css):

@import "tailwindcss";
@source "../node_modules/@fanvue/ui";
@import "@fanvue/ui/styles/theme.css";

4. Load Inter font

Load the Inter typeface via Google Fonts or @fontsource-variable/inter:

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:[email protected]&display=swap" rel="stylesheet" />

or

npm i @fontsource-variable/inter

Usage

import { Button } from "@fanvue/ui";

function App() {
  return (
    <Button variant="primary" size="40">
      Click me
    </Button>
  );
}

Animated icons

@fanvue/ui/animated-icons ships animated twins of the icons that have one. Each is exported under the same name as the static icon and renders in exactly the same box, so switching is a one-line change and nothing in your layout moves:

import { HeartIcon } from "@fanvue/ui";                // static
import { HeartIcon } from "@fanvue/ui/animated-icons";  // animates on hover

<HeartIcon size={24} />;

They live on their own subpath and depend on the optional motion peer, so @fanvue/ui consumers never pay for Motion unless they import from here.

Not every icon has a twin — an icon is only mapped once its animated artwork has been compared against ours — so a missing export means the pair was rejected or upstream has no equivalent. SpinnerIcon is deliberately absent: a loading indicator must not wait for a hover. Keep using the static one with <SpinnerIcon spin />, which respects reduced motion, or Loader.

Nothing animates when the user has asked for reduced motion (prefers-reduced-motion: reduce), including animations you start yourself through controlRef.

By default an icon animates while hovered. To drive it from a parent instead — an icon inside a button, say — pass a controlRef, which also turns the hover trigger off. Drive it from focus as well as hover: the <svg> is not focusable, so a keyboard user reaching the button gets nothing from hover alone.

const icon = useRef<AnimatedIconHandle>(null);

<button
  onMouseEnter={() => icon.current?.startAnimation()}
  onMouseLeave={() => icon.current?.stopAnimation()}
  onFocus={() => icon.current?.startAnimation()}
  onBlur={() => icon.current?.stopAnimation()}
>
  <HeartIcon controlRef={icon} /> Favourite
</button>;

The animated artwork is stroke-only, so these icons take no filled prop — passing one is a type error rather than a silent no-op. Where our static twin is also stroked artwork the animated one is drawn at the same stroke weight; where the static twin is fill-painted there is no stroke to match, so the animated outline can read a little lighter. Browse what is available in Storybook under Foundations → Icons with animated switched on: icons badged anim have a twin, and clicking a card copies the right import. Artwork and animations come from lucide-animated (MIT), built on Lucide (ISC) and in part Feather (MIT) — the full licence texts are in THIRD-PARTY-NOTICES.md, which ships with the package.

Theming

Customize the theme by overriding CSS variables:

:root {
  --color-primary-500: #00aeef;
  --color-neutral-500: #6b7280;
  --color-background-0: #ffffff;
}

Development

Prerequisites

  • Node.js 20+
  • pnpm 9+

Installation

pnpm install
pnpm dev
pnpm storybook

Scripts

CommandDescription
Development
pnpm devStart Vite dev server
pnpm dev:watchRebuild dist/ on change (live-reload into apps)
pnpm buildBuild the library for production
pnpm previewPreview production build
Testing
pnpm testRun unit tests
pnpm test:watchRun tests in watch mode
pnpm test:coverageRun tests with coverage report
pnpm test:storybookRun Storybook interaction tests
pnpm test:e2eRun Playwright E2E tests
pnpm typecheckRun TypeScript type checking
Linting & Formatting
pnpm lintCheck for lint errors (Biome)
pnpm lint:fixAuto-fix lint errors
pnpm formatFormat code
Storybook
pnpm storybookStart Storybook dev server on port 6006
pnpm build-storybookBuild Storybook static site
Icons
pnpm icons:syncRe-import icons from Figma and regenerate components, tests, stories
pnpm icons:animatedRe-import animated icons from the lucide-animated registry and regenerate
Tokens & Build
pnpm build:dictionaryGenerate styles from design tokens
pnpm build:showcaseBuild the showcase site
pnpm size-limitCheck bundle size
Publishing
pnpm publish:dry-runBuild and dry-run npm publish

Live-reloading into pandora/eden

To iterate on a component and see it live in eden (local.fanvue.com) without publishing:

  • Easiest: from the pandora repo root, run pnpm start:localui. It runs this library's watch build automatically and points eden at this checkout's dist/. See pandora's README ("Live-reloading @fanvue/ui from a local checkout"). Variants: pnpm start:dev:localui and pnpm start:docker:localui pick up the matching env files and handle AWS auth.
  • Manual: run pnpm dev:watch here, and start eden with USE_LOCAL_FANVUE_UI=1 (or pnpm --filter @pandora/eden start:localui).

Requires this repo checked out beside pandora (or FANVUE_UI_PATH set in pandora). Component markup, Tailwind classes and design tokens all hot-reload: pandora's eden/postcss.config.mjs redirects the @fanvue/ui/styles/theme.css import to this checkout's src/styles/theme.css, so token edits show up without a published (pre)release.

Figma + Storybook Integration

This library is integrated with Figma through Chromatic Connect. View the complete documentation in Storybook:

pnpm storybook
# Navigate to "Documentation > Figma Integration"

Commit Convention

This project uses Conventional Commits. Commit messages are validated by commitlint.

# Examples
feat(button): add loading state
fix: resolve focus ring issue
docs: update installation guide

For guided commit messages, install Commitizen globally:

npm i -g commitizen

Then use cz instead of git commit.

Contributing

See CONTRIBUTING.md for guidelines.

Security

See SECURITY.md for reporting vulnerabilities.

License

Apache 2.0 © Shift Holdings Ltd

版本与发布记录

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

版本发布日期距今
3.50.0latest2026/11/122 天前
3.49.02026/11/095 天前
3.48.02026/11/049 天前
3.47.02026/11/0211 天前
3.46.02026/10/3114 天前
3.45.02026/10/2816 天前

其他发布通道:alpha → 0.1.0-alpha.3。

关于 @fanvue/ui 的常见问题

@fanvue/ui 是什么?

React component library built with Tailwind CSS for Fanvue ecosystem

如何安装 @fanvue/ui?

在项目目录运行 npm install @fanvue/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ^19.0.0)、react-dom(^18.0.0 || ^19.0.0)、tailwindcss(^4.0.0)、@radix-ui/react-slot(^1.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fanvue/ui 支持 TypeScript 吗?

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

@fanvue/ui 支持 ESM 还是 CommonJS?

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

@fanvue/ui 需要什么版本的 Node.js?

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

@fanvue/ui 可以商用吗?

@fanvue/ui 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@fanvue/ui 的下载量有多少?

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

@fanvue/ui 还在维护吗?

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