@ds-gn/ui

中文文档
0.14.0发布于 2026/11/13MITTypeScriptES Module近 30 天下载 3053

UI components for the DS-GN Design System

原始使用文档
文档目录8 节
  1. Install
  2. Quick start
  3. React
  4. Package exports
  5. Server rendering
  6. Before components register
  7. Support
  8. License

DS-GN

@ds-gn/ui

Framework-agnostic web components and React wrappers for the DS-GN Design System.

Public Beta · Website · Documentation · Component reference · Changelog · Public repository

npm's Repository link points to our private build repository, which is required for Trusted Publishing. For examples and issue reporting, visit our public design-system repository.

Install

Choose your package manager:

npm install @ds-gn/ui @ds-gn/tokens
pnpm add @ds-gn/ui @ds-gn/tokens
bun add @ds-gn/ui @ds-gn/tokens

Install the tokens package directly because your application imports its stylesheets. Both packages come from public npm and require no .npmrc or entitlement token.

Quick start

Import the design tokens once in your application stylesheet:

@import '@ds-gn/tokens/public';
@import '@ds-gn/tokens/theme';
@import '@ds-gn/tokens/properties';

All three are required. properties registers the typed custom properties the components' styles depend on — a shadow root cannot register @property itself, so without this import those styles are silently dropped rather than erroring (transforms stop applying, anchored panels land in the wrong place).

Then import only the components you use. Importing a component registers its custom element:

import '@ds-gn/ui/button';
<dsgn-button appearance="outline">Get started</dsgn-button>

React

Official React wrappers are generated for every component. React is an optional peer dependency, so install it in your application.

import { Button } from '@ds-gn/ui/react';

export function Cta() {
  return <Button appearance="outline">Get started</Button>;
}

The wrappers retain their plain component names (Button, Input, and so on). Alias an import if it conflicts with a local component:

import { Button as DsgnButton } from '@ds-gn/ui/react';

Custom events are exposed as on<EventName> props named after their underlying dsgn-* events, such as onDsgnInput and onDsgnImageError.

Package exports

ExportPurpose
@ds-gn/ui/<component>Registers one custom element, such as button
@ds-gn/ui/<component>/propsComponent property definitions and supporting exports
@ds-gn/ui/reactTyped React wrappers for every component
@ds-gn/ui/logoLogo string helpers
@ds-gn/ui/logo/mark.svgDS-GN logo mark
@ds-gn/ui/logo/full.svgFull DS/GN logo for light backgrounds
@ds-gn/ui/logo/light.svgFull DS/GN logo for light backgrounds
@ds-gn/ui/logo/dark.svgFull DS/GN logo for dark backgrounds
@ds-gn/ui/layout.cssOptional pre-upgrade styles for page layout
@ds-gn/ui/hero/fallback.cssOptional pre-upgrade styles for Hero
@ds-gn/ui/playground-manifestMachine-readable component playground metadata

The string helpers inherit currentColor for theme-aware lettering and keep the slash orange. Use getLogoHtml({ size: 24 }) to render the full artwork at a given height with its accessible name.

Server rendering

  • Node SSR hosts (including Next, Remix, Nuxt, SvelteKit, Astro, and TanStack Start on Node): importing @ds-gn/ui/react during server rendering is safe. The server emits an inert <dsgn-*> tag that upgrades on the client. Declarative Shadow DOM is not emitted, so a brief unstyled frame is possible before upgrade; the pre-upgrade stylesheets below cover the layout components. Reactive properties are applied client-side; pass id, class, and similar values as normal attributes.
  • Cloudflare workerd (including TanStack Start on Workers): full SSR is not currently supported because the custom element cannot be evaluated in the worker runtime. Load the wrapper client-only, such as behind a ClientOnly boundary with a lazy import.

Before components register

When your HTML is rendered before the component scripts run (server rendering or static pages), import the optional pre-upgrade stylesheets in your page CSS:

@import '@ds-gn/ui/layout.css';
@import '@ds-gn/ui/hero/fallback.css'; /* only if you use dsgn-hero */

They apply only until each element registers. layout.css holds Container, Nav, FeatureTabs and Footer to their final gutters and section spacing, reserves the nav bar's height, and keeps the nav's links and dropdowns hidden until it lays them out. hero/fallback.css does the same for every Hero layout. Without them, content can shift or flash as unstyled text while the scripts load.

Public Beta components and compatibility policy

The Public Beta includes 32 custom elements:

GroupIncluded components
App-capableButton (dsgn-button), DropdownMenu (dsgn-dropdown-menu), Field (dsgn-field), Input (dsgn-input), Modal (dsgn-modal), SegmentedControl (dsgn-segmented-control), Select (dsgn-select), Table (dsgn-table), Toaster (dsgn-toaster)
Display and layoutBackground (dsgn-background), Badge (dsgn-badge), Card (dsgn-card), CodeBlock (dsgn-code-block), Container (dsgn-container), Divider (dsgn-divider), Grid (dsgn-grid), Stack (dsgn-stack)
ContentHeading (dsgn-heading), Text (dsgn-text), Icon (dsgn-icon), Image (dsgn-image), Callout (dsgn-callout), CodeSnippet (dsgn-code-snippet)
Marketing and compositionHero (dsgn-hero), HeadingBlock (dsgn-heading-block), FeatureItem (dsgn-feature-item), FeatureTabs (dsgn-feature-tabs), FormBlock (dsgn-form-block)
NavigationNav (dsgn-nav), NavLink (dsgn-nav-link), NavDropdownColumn (dsgn-nav-dropdown-column), Footer (dsgn-footer)

Modal ships in the Public Beta. No currently exported custom element is excluded. The aurora mesh engine is an internal rendering helper, not a custom element or package export. Avatar and the other app-grade components on the roadmap are post-launch work.

While the package remains 0.x:

  • The listed components are supported for consumer evaluation and production trials, but their APIs may change before 1.0.
  • Patch releases do not intentionally break documented APIs. Planned breaking changes ship in a minor release with migration guidance.
  • A deprecated API remains available for at least one complete minor release and at least 90 days, whichever is longer, before removal. Security, legal, or broken-platform emergencies may require faster changes.
  • The compatibility contract covers documented component subpaths, custom element tags, attributes and properties, slots, methods, events, CSS parts and custom properties, and generated React wrappers. Undocumented internals are not public API.

Support

Search or report package issues in the public issue tracker. For questions, email [email protected].

License

This package is available under the MIT License included in LICENSE. Third-party materials included in the distribution remain subject to the licenses listed in THIRD_PARTY_NOTICES.

版本与发布记录

@ds-gn/ui 共发布 23 个版本,首次发布于 2026/10/10;过去 12 个月发布了 23 个版本。

版本发布日期距今
0.14.0latest2026/11/13今天
0.13.02026/11/085 天前
0.12.22026/11/067 天前
0.12.12026/11/0211 天前
0.12.02026/11/0211 天前
0.11.32026/10/3014 天前

其他发布通道:oidc-test → 0.5.0-oidc.37992622193.1。

关于 @ds-gn/ui 的常见问题

@ds-gn/ui 是什么?

UI components for the DS-GN Design System

如何安装 @ds-gn/ui?

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

@ds-gn/ui 支持 TypeScript 吗?

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

@ds-gn/ui 支持 ESM 还是 CommonJS?

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

@ds-gn/ui 可以商用吗?

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

@ds-gn/ui 的下载量有多少?

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

@ds-gn/ui 还在维护吗?

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