@bergetai/ui

中文文档
0.29.0发布于 2026/10/27MITTypeScriptES Module近 30 天下载 6567

Berget Design System - Scandinavian-inspired design system with console aesthetic

原始使用文档
文档目录5 节
  1. Installation
  2. Peer dependencies
  3. Setup (one stylesheet, imported once)
  4. Usage
  5. Architecture

@bergetai/ui

Berget's React design system, built on Base UI, Tailwind CSS v4, and the shadcn component conventions. Published to the public npm registry; consumed by console, landing-page, and the Keycloak theme.

Installation

pnpm add @bergetai/ui

Peer dependencies

PackageRangeWhy
react / react-dom^19App owns the React runtime (single copy)
tailwindcss^4.1Utility generation happens in the consumer's build
lucide-react^1Icon set
motion^12Animation (only where used)
shiki^4Syntax highlighting (only @bergetai/ui/shiki)
three, @react-three/fiberoptionalOnly @bergetai/ui/neural-flow (WebGL illustration)

pnpm ≥ 8 and npm ≥ 7 install peers automatically; nothing extra to manage.

Setup (one stylesheet, imported once)

/* app/globals.css */
@import 'tailwindcss';
@import '@bergetai/ui/styles';
/* No @source needed: the stylesheet scans this package's own dist for you. */

Import order matters: @import 'tailwindcss' first, then @bergetai/ui/styles (tokens, base layer, component keyframes). Do not @import 'tailwindcss' anywhere else.

Why no @source is needed: Tailwind ignores node_modules during content detection, so the shipped stylesheet registers the package's own emitted modules via an @source that resolves relative to itself. If you import the sheet from the monorepo source (Storybook), add your own @source for the package's src/ instead.

Usage

import { Button, Card, CardHeader, CardTitle, CardContent } from '@bergetai/ui';
  • RSC-safe. Every interactive module ships a "use client" prologue; render @bergetai/ui components directly from Server Components.
  • Composition, not wrapping. Base UI semantics apply: use the render prop (never asChild — deprecated), and style <a> elements with buttonVariants() rather than rendering links through Button.
  • Tokens only. Never use raw palette classes (bg-blue-500), arbitrary values (p-[13px]), or manual dark: colour overrides — dark mode and light mode are entirely token-driven ([data-theme='light']). className on a component is for layout (margin, placement, width), not restyling; missing looks belong in the DS as variants.
  • Subpath exports. @bergetai/ui (components), @bergetai/ui/styles (CSS tokens), @bergetai/ui/shiki (highlighter), @bergetai/ui/neural-flow (WebGL; pulls three as optional peer).

Architecture

  • src/primitives/ — shadcn-generated Base UI primitives (generated via npx shadcn@latest add, never hand-modified; refreshed with --overwrite)
  • src/components/ — branded wrappers: tokens, cva variants, data-slot attributes, public API
  • src/styles/index.css — token source of truth: brand palette (Section A, OKLCH) → semantic tokens (B) → component-scoped tokens (C) → Tailwind @theme mapping (D)

Development: pnpm i at the repo root, then pnpm --filter @bergetai/ui dev (build watch), pnpm storybook, pnpm typecheck, pnpm spellcheck. Component work follows the .agents/skills/add-component skill.

Releases: workflow_dispatch on release.yml bumps the version, tags, and publishes to the npm registry via Trusted Publishing (OIDC).

版本与发布记录

@bergetai/ui 共发布 73 个版本,首次发布于 2026/07/06;过去 12 个月发布了 73 个版本。

版本发布日期距今
0.29.0latest2026/10/2711 天前
0.28.02026/10/2712 天前
0.27.02026/10/2612 天前
0.26.02026/10/2316 天前
0.25.02026/10/2316 天前
0.24.02026/10/2216 天前

关于 @bergetai/ui 的常见问题

@bergetai/ui 是什么?

Berget Design System - Scandinavian-inspired design system with console aesthetic

如何安装 @bergetai/ui?

在项目目录运行 npm install @bergetai/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、shiki(^4.3.1)、motion(^12.38.0)、react-dom(^19.0.0)、tailwindcss(^4.1.0)、lucide-react(^1.23.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bergetai/ui 支持 TypeScript 吗?

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

@bergetai/ui 支持 ESM 还是 CommonJS?

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

@bergetai/ui 可以商用吗?

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

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

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

@bergetai/ui 还在维护吗?

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