@ecopages/radiant-ui

中文文档
0.3.6发布于 2026/11/13MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 5138

Accessible light-DOM UI components built with @ecopages/radiant

原始使用文档
文档目录5 节
  1. Packages
  2. Develop
  3. Checking layout and styles
  4. Using radiant-ui
  5. Story map

@ecopages/radiant-ui

Accessible light-DOM UI components built with @ecopages/radiant and @ecopages/jsx, documented in Storybook.

Custom elements use the rui-* tag prefix. Public TypeScript / JSX exports use the Rui* prefix.

This project is not a React app. JSX compiles through @ecopages/jsx.

Packages

PathRole
src/components/ui@ecopages/radiant-ui component library (APG-oriented widgets)
@ecopages/storybook-radiant-viteStorybook framework for Radiant (client + SSR → hydrate)
src/components/client, src/components/ssr, src/storiesFramework dogfood demos (not the published UI catalog)

Framework documentation (API, SSR contract, Vitest, limitations):
../storybook-radiant-vite/README.md

Library overview and conventions: Storybook Introduction (src/Introduction.mdx). Component authoring: src/components/ui/README.md.

Develop

pnpm install
pnpm run storybook

Open the URL Storybook prints (default port 6006).

Checking layout and styles

  • Automated (CI-friendly): pnpm run test:storybook runs each story’s play function in a real browser (Vitest + Playwright). Layout helpers live in .storybook/layout-assertions.ts (overflow, --text-control-input font size, popover viewport bounds) — see Components/DateRangePicker → NarrowLayout. The shared typography file defines the type scale and input sizing; each complete theme supplies --font-sans, --font-heading, and --font-mono.
  • Manual: run pnpm run storybook and use the browser’s responsive mode or resize the preview; no third-party visual service required.
  • Pixel snapshots (optional): Vitest browser mode supports Playwright toHaveScreenshot() with baselines committed in the repo if you want image diffs without Chromatic.

Useful scripts:

pnpm run test            # Vitest (storybook + unit browser projects)
pnpm run test:storybook  # Story interaction/render tests (CI)
pnpm run test:ssr:smoke  # SSR smoke (6 stories × client/ssr-static/ssr-hydrate; runs on PRs)
pnpm run test:ssr        # Full Components/* SSR matrix (run on demand)
pnpm run typecheck
pnpm run lint
pnpm run build:lib       # generate exports + build JS/types + compile CSS

test:storybook runs stories through the Vitest addon (no Storybook dev server). test:ssr:smoke and test:ssr spawn Storybook, visit stories in Playwright, and fail on .radiant-ssr-error banners or disallowed page errors. For stories expected to mount, the harness waits briefly for content or an SSR error banner before checking the result. Empty mounts fail only for stories listed in scripts/storybook-ssr-harness.ts (expectsMount / allowEmptyMount).

Published CSS under dist/ is already compiled (Tailwind @apply resolved). Theme and token values remain CSS custom properties so apps can swap themes at runtime. The package does not minify CSS. Published declaration imports are rewritten to package-relative paths during build:lib, and test:package rejects unresolved source aliases.

Entries are code-split: a module imported by several entries, such as the field control protocol or a component class, is emitted once into dist/chunks/ and listed in sideEffects. This keeps module state, like the registerFieldControl registry, and instanceof checks between entries on one copy. Chunk names are content hashes and must not be imported; use only the documented entries. Without a bundler, the root index.js loads many chunk files. src/built-package/*.test.ts import dist/ and run in their own built-package vitest project, which the unit project excludes. Its globalSetup (.storybook/built-package.global-setup.ts) checks that dist/ and dist/chunks exist and are newer than the shipped sources, and the project's tests fail with pnpm --filter @ecopages/radiant-ui build:lib as the fix; a bare pnpm test without a build still runs the other projects. The freshness check compares mtimes, so a formatting-only source edit also asks for a rebuild. test:all builds first. build:lib also bundles an entry with esbuild to confirm the chunks/*.js sideEffects glob keeps the registrations, and test:package fails when a dist/chunks file matches no sideEffects glob.

Component entries register their nested custom elements as well as their own host. The package's sideEffects list preserves source *.script.ts / *.script.tsx registration modules during the library build and built index.js entries during consumer bundling. Removing those source side effects can leave nested Derived Trees as empty tags during SSR. build:lib runs test:package against isolated imports of the built date compositions and sidebar trigger to verify registration and server-rendered markup.

Using radiant-ui

Rui* JSX props remain camelCase. In direct custom-element HTML, camelCase @prop names use kebab-case attributes (for example, mobileBreakpoint is mobile-breakpoint).

import '@ecopages/radiant-ui/themes/default';
import '@ecopages/radiant-ui/styles.css';
import '@ecopages/radiant-ui/disclosure';
import { RuiDisclosure, RuiDisclosureGroup } from '@ecopages/radiant-ui/disclosure';
import { RuiButton } from '@ecopages/radiant-ui/button';

Radiant UI ships one accessible default theme: Radiant Default with near-Zed spacing (28, 32, and 36px controls, 14px text), a restrained control radius (4.2px at the default 0.7 scale), flat controls, and light translucent borders (11%). Optional complete themes and named compact variants such as GitHub Compact, Vercel, Material Design, High Contrast, Windows 95, Mac OS Classic, macOS, and Zed live in @ecopages/radiant-themes. The default's OKLCH color families can be retuned by overriding --rui-primary, --rui-secondary, and --rui-neutral after importing the theme. --rui-density, --rui-neutral-tint (how strongly the greys carry the neutral hue, default 1.3), --rui-radius-scale (default 0.7), and --rui-border-alpha (default 11%) complete its tuning surface. Optional themes set their own shape, spacing, typography, and component details. The default responds to reduced-motion, increased-contrast, and forced-colors preferences.

Or register every custom element from the root entry (still load theme + styles separately):

import '@ecopages/radiant-ui/themes/default';
import '@ecopages/radiant-ui/styles.css';
import '@ecopages/radiant-ui';

Base bundle (Tailwind, shared utilities and the default theme; component styles still come from styles.css):

import '@ecopages/radiant-ui/radiant-ui.css';

Design tokens and themes: see DESIGN.md. Agent working rules: AGENTS.md.

Story map

  • Components/ — radiant-ui catalog (src/components/ui)
  • Client/ — framework demos ported from Radiant playground/vite
  • SSR/ — framework demos ported from Radiant playground/vite-nitro

版本与发布记录

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

版本发布日期距今
0.3.6latest2026/11/13今天
0.3.52026/11/13今天
0.3.42026/11/085 天前
0.3.32026/11/085 天前
0.3.22026/11/085 天前
0.3.12026/11/076 天前

其他发布通道:beta → 0.1.0-beta.2,rc → 0.1.0-rc.19。

关于 @ecopages/radiant-ui 的常见问题

@ecopages/radiant-ui 是什么?

Accessible light-DOM UI components built with @ecopages/radiant

如何安装 @ecopages/radiant-ui?

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

@ecopages/radiant-ui 支持 TypeScript 吗?

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

@ecopages/radiant-ui 支持 ESM 还是 CommonJS?

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

@ecopages/radiant-ui 可以商用吗?

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

@ecopages/radiant-ui 的下载量有多少?

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

@ecopages/radiant-ui 还在维护吗?

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