@bardioc/ui

中文文档
0.7.39发布于 2026/11/04MITTypeScriptES Module近 30 天下载 3463

Bardioc UI component library: Bardioc components and Shadcn primitives for BardiocOS apps

原始使用文档
文档目录9 节
  1. Installation
  2. Entry points
  3. Usage guidelines
  4. Shadcn primitives are read-only
  5. Build
  6. React Server Components
  7. Usage
  8. Styles
  9. Development

@bardioc/ui

Bardioc UI component library for BardiocOS apps. Combines a custom Bardioc component layer with Shadcn/Radix primitives on top of Tailwind CSS 4.

Installation

pnpm add @bardioc/ui
# peers (provide in the consumer app)
pnpm add react react-dom @bardioc/i18n-core

Entry points

@bardioc/ui ships only subpath exports. Import the surface you need rather than the package root.

SubpathPurpose
@bardioc/ui/componentsBardioc components (canonical non-chart surface)
@bardioc/ui/components/chartsBardioc chart components (Recharts-backed)
@bardioc/ui/components/metricsBardioc metric components
@bardioc/ui/shadcnShadcn/Radix primitives (non-chart) — use as namespace import
@bardioc/ui/shadcn/chartShadcn chart primitives (Recharts-backed)
@bardioc/ui/hooksReusable React hooks
@bardioc/ui/libUtility functions (cn, color helpers, pagination, ...)
@bardioc/ui/typesShared TypeScript types
@bardioc/ui/constsShared constants
@bardioc/ui/iconsSVG icon components
@bardioc/ui/styles/*CSS entry points (globals.css, component stylesheets)
@bardioc/ui/postcss.configPostCSS preset for consumers

Usage guidelines

Component choice, design tokens, implementation patterns and UI copy rules ship with the package in docs/ (node_modules/@bardioc/ui/docs/INDEX.md once installed).

Shadcn primitives are read-only

Files under src/components/shadcn/ are managed by the shadcn CLI. Do not hand-edit them. To change visuals or behavior, create or edit a Bardioc component under src/components/bardioc/<category>/ that overrides or composes the primitive.

Build

tsc compiles each source file to one ESM file with its declarations, and tsc-alias rewrites #-aliases to relative .js paths. One file per module lets a consumer's bundler drop every file it does not import, and keeps one copy of each module across subpaths.

React Server Components

Only the shadcn source files carry 'use client' directives; the barrels and most Bardioc components do not. When consuming @bardioc/ui/{components,shadcn,hooks} from a React Server Components environment (e.g. Next.js App Router), mark the consuming file with 'use client' yourself:

'use client';
import { Command } from '@bardioc/ui/shadcn';

Non-RSC environments (Vite, plain Webpack, Storybook, Vitest) need no special handling.

Usage

import { Button, DataTable } from '@bardioc/ui/components';
import { RevenueChart } from '@bardioc/ui/components/metrics';
import * as Shadcn from '@bardioc/ui/shadcn';
import { ChartContainer } from '@bardioc/ui/shadcn/chart';
import { cn } from '@bardioc/ui/lib';
import '@bardioc/ui/styles/bardioc-ui.css'; // pre-compiled theme + utilities

Styles

Components in this package style themselves with Tailwind utility classes (className="bg-primary text-primary-foreground rounded-md ..."). Tailwind classes are not real CSS — they are tokens that Tailwind translates into CSS rules at build time. Without that translation, the markup has class attributes that mean nothing to the browser, and components render unstyled.

To make components render correctly, import the pre-compiled CSS bundle once in your app's entry file:

// src/main.tsx (or app/layout.tsx, etc. — once per app)
import '@bardioc/ui/styles/bardioc-ui.css';

That bundle (~200 KB minified) contains:

  • The full Tailwind v4 runtime base layer
  • Every utility class actually used by Bardioc and shadcn components (tree-shaken at our build — unused utilities are excluded)
  • Bardioc theme variables and color palette
  • The shadcn theme layer (CSS custom properties for --background, --primary, --ring, etc., in both light and dark modes)
  • tw-animate-css animation utilities
  • Per-component custom CSS that lives alongside our components

Consumers do not need Tailwind installed to use the library. They do not need to configure @source or a content array. The single CSS import provides everything our components reference.

Two CSS entry points — which to use

EntryWhen to use
@bardioc/ui/styles/bardioc-ui.cssExternal consumers (npm install). Pre-compiled, fully self-contained. Default.
@bardioc/ui/styles/globals.cssMonorepo siblings only. Source-style; you run Tailwind yourself and add @source.

globals.css contains @import 'tailwindcss' plus @source '../../../../packages/**/...' directives that resolve only within this monorepo. It exists so siblings can extend Tailwind with their own app-specific class names while still sharing our theme tokens. In a node_modules install, those @source paths point at nonsense and the file does not work. Use bardioc-ui.css instead.

How the CSS is produced

The package build runs in three steps:

  1. tsc and tsc-alias compile each source file to dist/ (no CSS handling).
  2. node scripts/copy-assets.mjs copies the raw source CSS files (globals.css, shadcn.css, components/*.css, etc.) into dist/styles/ for monorepo-sibling consumers.
  3. tailwindcss -i src/styles/build-bundle.css -o dist/styles/bardioc-ui.css --minify runs the Tailwind v4 CLI: it scans packages/ui/src/**/*.{ts,tsx} for class names referenced in our JSX, generates only the matching utility CSS, prepends the theme layer, and writes the single minified bundle.

The Tailwind compile step is what lets external consumers skip the toolchain entirely. The build artifact is portable, framework-agnostic CSS — the same file works in Next.js, Vite, plain HTML, or any bundler that supports CSS imports.

Theme overrides

bardioc-ui.css defines tokens as CSS custom properties (e.g. --primary, --background). Override them in consumer CSS after importing the bundle:

@import '@bardioc/ui/styles/bardioc-ui.css';

:root {
  --primary: oklch(0.6 0.2 250);
  --radius: 0.5rem;
}

For deeper theming (adding new utility colors, custom breakpoints, etc.), use the source-style globals.css path from a monorepo sibling and extend Tailwind directly.

Development

pnpm --filter @bardioc/ui build         # tsc + copy CSS + tailwind compile
pnpm --filter @bardioc/ui check-types
pnpm --filter @bardioc/ui test
pnpm --filter @bardioc/ui pack:check    # inspect what would be published

The package emits ESM JavaScript with declaration files. Tests live in packages/ui/tests/unit/ and are excluded from dist.

版本与发布记录

@bardioc/ui 共发布 60 个版本,首次发布于 2026/07/22;过去 12 个月发布了 60 个版本。

版本发布日期距今
0.7.39latest2026/11/043 天前
0.7.382026/11/025 天前
0.7.372026/10/318 天前
0.7.362026/10/299 天前
0.7.352026/10/2810 天前
0.7.342026/10/2711 天前

关于 @bardioc/ui 的常见问题

@bardioc/ui 是什么?

Bardioc UI component library: Bardioc components and Shadcn primitives for BardiocOS apps

如何安装 @bardioc/ui?

在项目目录运行 npm install @bardioc/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.2)、react-dom(^19.2)、next-themes(^0.4.6)、react-hook-form(^7.64.0)、@bardioc/i18n-core(^0.1.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bardioc/ui 支持 TypeScript 吗?

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

@bardioc/ui 支持 ESM 还是 CommonJS?

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

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

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

@bardioc/ui 可以商用吗?

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

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

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

@bardioc/ui 还在维护吗?

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