@db-ux/core-components
v4.7.2
Published
General technical components (styling, fonts and icons) out of DB UX Design System (Version 3)
Readme
@db-ux/core-components
A library containing all styles for components of DB UX Design System v3.
Note Furthermore we currently support these additional JavaScript frameworks, with more coming soon:
Please take a look at your desired framework to retrieve more information.
For additional information besides the frameworks see our Getting started.
If you just need the styling follow this:
Package Relationship
✅ Do I need foundations if I install components?
No! The @db-ux/core-components package automatically includes all the foundations (@db-ux/core-foundations) you need. You only need to include one package:
- Use
@db-ux/core-components- If you want to use UI components (buttons, inputs, etc.) - Use
@db-ux/core-foundations- If you only need design tokens, colors, spacing, fonts, and assets without any component styles
Install
npm i @db-ux/core-components
Note: This automatically includes
@db-ux/core-foundationsas a dependency, if you usenpm. If you usepnpmyou need to install@db-ux/core-foundationsas well.
Styling Dependencies
Import the styles in css. Based on your technology the file names could be different.
relative: asset path point to../assetswebpack: asset path point to~@db-ux/core-foundations/assetsrollup: asset path point to@db-ux/core-foundations/assets
Important: These bundled files automatically include all dependencies from foundations (design tokens, colors, fonts, etc.) and all components - everything you need in one import!
Import
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 Note: 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). We might provide a specific configuration necessary to mitigate those problems in the near future. To keep CSS output stable in the meantime, configurevite.config.tslike 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"
)
)
}
}
});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).
Optimize dependencies
If you only need some of the components or some features from @db-ux/core-foundations, you shouldn't include the bundled file.
In the case you want to include only some components, and you could do it like this:
/* The theme contains all props required for components like spacings, colors, ... */
@import "@db-ux/core-foundations/build/styles/bundle.css";
/* The font include uses default font families based on your bundling paths (relative, absolute, webpack, rollup) */
@import "@db-ux/core-foundations/build/styles/fonts/rollup.css";
/* The required styles will normalize css and add focus and default font to body */
@import "@db-ux/core-foundations/build/styles/defaults/default-required.css";
/* The default setting for :root, adds a color space (neutral-bg-basic-level-1) and a density (regular). */
@import "@db-ux/core-foundations/build/styles/defaults/default-root.css";
/* Optional: Add animations / transitions for components */
@import "@db-ux/core-components/build/styles/component-animations.css";
/* Optional: Add data-icon/data-icon-trailing to global attributes to enable icons for components */
@import "@db-ux/core-foundations/build/styles/icons/rollup.css";
/* Optional: Add components */
@import "@db-ux/core-components/build/components/button/button.css";
@import "@db-ux/core-components/build/components/input/input.css";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.
