@daikin-oss/design-system-web-components

中文文档
2.1.0发布于 2026/09/24MITTypeScriptESM + CJS近 30 天下载 2820

Design system using web components

原始使用文档
文档目录12 节
  1. Usage
  2. Fonts
  3. Dark Mode and Brands/Themes
  4. Contribution
  5. Setup
  6. Build
  7. Documentation
  8. Testing
  9. Linting and Type checking
  10. Design Tokens
  11. TailwindCSS
  12. Developing with VSCode

Daikin Design System - Web Components

This project is an implementation of the Daikin Design Kit using Web Components.


Usage

Start by installing the package:

npm install @daikin-oss/design-system-web-components @daikin-oss/dds-tokens

To deploy the necessary CSS variables, import the CSS or SCSS from the @daikin-oss/dds-tokens package: For details, please check the dds-tokens repository.

import "@daikin-oss/dds-tokens/css/daikin/Light/variables.css";

You can then import necessary components in your bundle (the .js extension is optional):

import "@daikin-oss/design-system-web-components/components/button/index.js";

Fonts

We use Roboto as the font for our UI components. This font is not included in our package, so developers will need to include it in their apps.

The required weights and variants are as follows:

  • Regular (400), Normal
  • Bold (700), Normal

With Google Fonts

If you can use an external CDN, you can use Google Fonts to load it.

<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=Roboto:wght@400;700&display=swap"
  rel="stylesheet"
/>

With Fontsource

If you want to deliver fonts within your app without relying on an external CDN, you can use a package like Fontsource to do this.

Install the package with:

npm install @fontsource/roboto

Then import it in your app:

import "@fontsource/roboto/400.css";
import "@fontsource/roboto/700.css";

Dark Mode and Brands/Themes

Due to the encapsulation of styles by the Web Components specification, how themes are applied may change in the future.

For dark-mode support and non-daikin brands, you need to add the tokens package and include the CSS reference in your html:

npm install @daikin-oss/dds-tokens

Dark Mode

Reference the CSS in HTML:

<link
  rel="stylesheet"
  href="node_modules/@daikin-oss/dds-tokens/build/css/DKN/Dark/variables.css"
  media="(prefers-color-scheme: dark)"
/>

Using CSS @import with prefers-color-scheme:

@import "@daikin-oss/dds-tokens/css/daikin/Dark/variables.css"
  (prefers-color-scheme: dark);

Other brands/themes

Reference the CSS in HTML:

<link
  rel="stylesheet"
  href="node_modules/@daikin-oss/dds-tokens/build/css/AAF/Dark/variables.css"
  media="(prefers-color-scheme: light)"
/>
<link
  rel="stylesheet"
  href="node_modules/@daikin-oss/dds-tokens/build/css/AAF/Dark/variables.css"
  media="(prefers-color-scheme: dark)"
/>

Using CSS @import with prefers-color-scheme:

@import "@daikin-oss/dds-tokens/css/aaf/Light/variables.css"
  (prefers-color-scheme: light);
@import "@daikin-oss/dds-tokens/css/aaf/Dark/variables.css"
  (prefers-color-scheme: dark);

Contribution

The following are instructions for package contributors.

Setup

Clone and install dependencies:

git clone https://github.com/dsv-rp/DDS.git
cd DDS

# install dependencies
npm i

# install Playwright browsers
npx playwright install

Build

To build files for production:

npm run build

Vite is used to transform TypeScript code into JavaScript that runs in modern browsers.

The built files are written to /dist.

Documentation

Storybook is used to document design system components/tools/examples.

To run in development mode:

# Web Components version
npm run storybook

# or React version
npm run storybook:react

To produce distributable files in /storybook-static/web-components and /storybook-static/react folder:

npm run build-storybook

Testing

There are currently two test suites: VRT (Visual Regression Test) and Interaction Test.

Visual regression testing, placed in *.visual.test.ts, is done by Playwright running in a container. To eliminate rendering differences between environments, the browser which takes the screenshots must run on a container.

Currently, Web Components has full support in most major frameworks except for React. As such, we test both Web Components by themselves, and also test when imported by React:

# start a container for running the browsers
docker compose up -d

# run VRT for Web Components and React versions
npm run test:visual

# stop the container
docker compose down

For Podman users, use podman-compose -f compose.podman.yaml or podman compose -f compose.podman.yaml instead of docker compose.

To update snapshots, use npm run test:visual-update


Interaction testing, placed in *.stories.ts, is performed by Storybook, which also uses Playwright internally. Interaction tests do not use containers since rendering differences between environments do not matter.

npm run test:interaction

Linting and Type checking

Linting is performed by ESLint for general linting of JavaScript and TypeScript, and lit-analyzer to type check bindings in lit-html templates. cSpell is used for spell checking. ls-lint is also used to ensure that consistent filenames are used.

To lint the project, run:

npm run lint
npx tsc -b

If you encounter an Unknown word error, add the word to the cspell-dictionary.txt.

Design Tokens

We manage and use design tokens to ensure consistency in our design system.

  1. Source of Truth: The tokens we use is the foundation of our design styles and was grabbed from https://github.com/dsv-rp/dds-tokens. These design tokens are deployed as CSS variables.

  2. Usage in Components: The components make use of design tokens by referencing CSS variables. Since they are integrated with Tailwind CSS, they are mostly used as utility classes, but in some cases they are directly referenced using var().

@ddsElement("daikin-link")
export class DaikinLink extends DDSElement {
  static override readonly styles = css`
    ${unsafeCSS(tailwindStyles)}

    :host([show-visited]:not([disabled])) a:visited {
      /* HERE */
      color: var(--dds-color-link-text-visited-default);
    }
  `;

  override render() {
    /* AND HERE (`text-ddt-*` classes) */
    return html`
      <a
        class="text-ddt-color-link-text-default hover:text-ddt-color-link-text-hover"
        href="https://www.example.com/"
      >
        ...
      </a>
    `;
  }
}

TailwindCSS

There is a custom daikinPlugin managed here.

Developing with VSCode

This project provides recommended extensions and workspace settings for VSCode.

References Daikin Design Kit

版本与发布记录

@daikin-oss/design-system-web-components 共发布 37 个版本,首次发布于 2024/05/25;过去 12 个月发布了 20 个版本。

版本发布日期距今
2.1.0latest2026/09/241 个月前
2.1.0-next.3next2026/09/241 个月前
2.1.0-next.22026/09/181 个月前
2.0.1-next.12026/09/151 个月前
2.0.02026/09/032 个月前
2.0.0-next.22026/09/022 个月前

关于 @daikin-oss/design-system-web-components 的常见问题

@daikin-oss/design-system-web-components 是什么?

Design system using web components

如何安装 @daikin-oss/design-system-web-components?

在项目目录运行 npm install @daikin-oss/design-system-web-components,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@daikin-oss/dds-tokens(^2.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@daikin-oss/design-system-web-components 支持 TypeScript 吗?

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

@daikin-oss/design-system-web-components 支持 ESM 还是 CommonJS?

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

@daikin-oss/design-system-web-components 可以商用吗?

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

@daikin-oss/design-system-web-components 的下载量有多少?

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

@daikin-oss/design-system-web-components 还在维护吗?

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