@db-ux/react-core-components

中文文档
6.3.2发布于 2026/11/11Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 5225

React components for @db-ux/core-components

原始使用文档
文档目录21 节
  1. Install
  2. Styling Dependencies
  3. Vite Plugin
  4. PostCSS Plugin (recommended)
  5. Manual CSS Setup
  6. Vite 8
  7. Next 16
  8. DB Theme
  9. Usage
  10. AI Agent Support
  11. Quick Start
  12. Code Quality
  13. Installation
  14. Setup
  15. Stylelint
  16. Installation
  17. Setup
  18. Deutsche Bahn brand
  19. Contributions
  20. Code of conduct
  21. License

@db-ux/react-core-components

Apache 2.0 license badge code style: prettier Conventional Commits PRs Welcome

A React library containing all styles & components of DB UX Design System (technical components). We also provide more information about specific components. This information is in our Design System documentation.

Install

pnpm add @db-ux/react-core-components @db-ux/core-components @db-ux/core-foundations --save-dev

Styling Dependencies

Vite Plugin

If you're using Vite, you can use the @db-ux/core-vite-plugin which simplifies the CSS setup to a single import.

pnpm add @db-ux/core-vite-plugin --save-dev

Add the plugin to your vite.config.ts:

import { defineConfig } from "vite";
import dbUxPlugin from "@db-ux/core-vite-plugin";

export default defineConfig({
    plugins: [dbUxPlugin()]
});

Then import the plugin in your CSS file:

/* index.css */
@import "@db-ux/core-vite-plugin/index.css";

📖 Learn more about @db-ux/core-vite-plugin node package

We recommend using the @db-ux/core-postcss-plugin to reduce your bundle size. It flattens CSS custom properties by resolving var(), calc(), color-mix(), and light-dark() at build time, removing unused declarations.

pnpm add @db-ux/core-postcss-plugin --save-dev

Configure it in vite.config.ts:

import { defineConfig } from "vite";
import { dbUxFlatten } from "@db-ux/core-postcss-plugin";

export default defineConfig({
    css: {
        transformer: "postcss", // required for Vite 8+ (default: 'lightningcss')
        postcss: {
            plugins: [dbUxFlatten()]
        }
    }
});

📖 Learn more about @db-ux/core-postcss-plugin node package

Manual CSS Setup

If you're not using Vite or prefer manual setup, import the styles in your main CSS file:

/* index.css */
@layer whitelabel-theme, db-ux;
/* You may want to include another theme here, this is a whitelabel theme! So instead of including the following line of code, please have a look at the DB Theme section */
@import "@db-ux/core-foundations/build/styles/theme/rollup.css"
    layer(whitelabel-theme);

@import "@db-ux/core-components/build/styles/bundle.css" layer(db-ux);

Vite 8

Starting with Vite 8, the default CSS minifier was changed to LightningCSS, which provides buggy transformations for modern CSS features used by the DB UX Design System (e.g. light-dark() CSS function). To keep CSS output stable, configure vite.config.ts like this:

// vite.config.ts
export default defineConfig({
    build: {
        cssMinify: "esbuild"
    }
});

Alternatively, you could define a browserslist based on your individual browser support strategy — which might be totally different from the list Vite 8 defines by default (targeting browsers from the early 2020s):

// Note: You need to install the required packages first:
// npm install -D lightningcss browserslist

// vite.config.ts
import { browserslistToTargets } from "lightningcss";
import browserslist from "browserslist";

export default defineConfig({
    css: {
        lightningcss: {
            targets: browserslistToTargets(
                browserslist(
                    ">= 0.5%, last 2 major versions, Firefox ESR, not dead"
                )
            )
        }
    }
});

Next 16

Starting with Next 16, the default CSS minifier was changed to LightningCSS, which provides buggy transformations for modern CSS features used by the DB UX Design System (e.g. light-dark() CSS function). We might provide a specific configuration necessary to mitigate those problems in the near future. To keep CSS output stable in the meantime, configure next.config.ts like this:

// next.config.ts

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
    experimental: {
        useLightningcss: true,
        lightningCssFeatures: {
            exclude: ["light-dark"]
        }
    }
};

export default nextConfig;

DB Theme

In case that you're building a website or application for Deutsche Bahn, you'll additionally have to install the DB Theme via the @db-ux/db-theme node package (even also available as an inner source node package, as described within that packages README).

Usage

import { DBButton } from "@db-ux/react-core-components";

<DBButton variant="brand" onClick={() => console.log("clicked")}>
    Add item to cart
</DBButton>;

AI Agent Support

For developers using AI coding assistants like GitHub Copilot or Amazon Q, we provide the @db-ux/agent-cli tool that automatically adds DB UX Design System documentation to your repository.

Quick Start

Run this command in your repository:

npx @db-ux/agent-cli

This will create or update .github/copilot-instructions.md with component documentation based on your installed @db-ux packages, helping AI agents provide better suggestions.

📖 Learn more about @db-ux/agent-cli node package

Code Quality

To enforce correct usage of DB UX Design System components in your React project, we provide the @db-ux/core-eslint-plugin ESLint plugin.

Installation

pnpm add eslint @db-ux/core-eslint-plugin @typescript-eslint/parser --save-dev

Setup

// eslint.config.js
import dbUx from "@db-ux/core-eslint-plugin";
import tsParser from "@typescript-eslint/parser";

export default [
    {
        files: ["**/*.ts", "**/*.tsx"],
        languageOptions: {
            parser: tsParser,
            parserOptions: {
                ecmaVersion: "latest",
                sourceType: "module",
                ecmaFeatures: { jsx: true }
            }
        },
        plugins: {
            "db-ux": dbUx
        },
        rules: dbUx.configs.recommended.rules
    }
];

📖 Learn more about @db-ux/core-eslint-plugin node package

Stylelint

To validate correct usage of DB UX Design System tokens in your CSS/SCSS, use the @db-ux/core-stylelint plugin.

Installation

pnpm add stylelint @db-ux/core-stylelint --save-dev

Setup

Add to your .stylelintrc.json:

{
    "plugins": ["@db-ux/core-stylelint"],
    "rules": {
        "db-ux/use-spacings": [true],
        "db-ux/use-sizing": [true],
        "db-ux/use-border-width": [true],
        "db-ux/use-border-radius": [true],
        "db-ux/use-border-color": [true]
    }
}

📖 Learn more about @db-ux/core-stylelint node package

Deutsche Bahn brand

As we'd like to perfectly support our users and customers on their digital journey, the usage of Deutsche Bahn brand and trademarks are bound of clear guidelines and restrictions even if being used with the code that we're providing with this product; Deutsche Bahn fully reserves all rights regarding the Deutsche Bahn brand, even though that we're providing the code of DB UX Design System products free to use and release it under the Apache 2.0 license. Please have a look at our brand portal at https://marketingportal.extranet.deutschebahn.com/ for any further questions and whom to contact on any brand issues.

For any usage outside of Deutsche Bahn websites and applications you aren't allowed to use any Deutsche Bahn brand and design assets as well as protected characteristics and trademarks, that for not including the DB Theme.

Contributions

Contributions are very welcome, please refer to the contribution guide.

Code of conduct

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone – have a look at our Contributor Covenant Code of Conduct.

License

This project is licensed under Apache-2.0.

版本与发布记录

@db-ux/react-core-components 共发布 200 个版本,首次发布于 2025/02/13;过去 12 个月发布了 119 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
6.3.2latest2026/11/11今天
6.3.12026/11/101 天前
6.3.02026/11/056 天前
6.2.12026/11/047 天前
6.2.1-optimized-icon-fonts-amount2-b78987enext2026/11/047 天前
6.2.02026/10/2913 天前

关于 @db-ux/react-core-components 的常见问题

@db-ux/react-core-components 是什么?

React components for @db-ux/core-components

如何安装 @db-ux/react-core-components?

在项目目录运行 npm install @db-ux/react-core-components,或使用 pnpm add / yarn add / bun add。

@db-ux/react-core-components 支持 TypeScript 吗?

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

@db-ux/react-core-components 支持 ESM 还是 CommonJS?

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

@db-ux/react-core-components 可以商用吗?

@db-ux/react-core-components 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@db-ux/react-core-components 的下载量有多少?

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

@db-ux/react-core-components 还在维护吗?

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