@db-ux/ngx-core-components
v5.1.3
Published
Angular components @db-ux/core-components
Readme
@db-ux/ngx-core-components
An Angular 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/ngx-core-components @db-ux/core-components @db-ux/core-foundations --save-devStyling Dependencies
Import the styles in your main CSS file:
/* styles.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);PostCSS Plugin (recommended)
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-devCreate a postcss.config.json in your project root:
{
"plugins": {
"@db-ux/core-postcss-plugin": {}
}
}Angular CLI (
@angular/build:application) only supports JSON-based PostCSS configs and loads plugins by name viarequire(). Works in bothng buildandng serve.
📖 Learn more about @db-ux/core-postcss-plugin node package
Resolve assets
The current default development config in angular.json doesn't use output hashing. This may cause an issue loading the fonts. Look at this for more information.
As a solution add "outputHashing": "media" to configurations/development in angular.json.
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
// app.component.ts
import { DBButton } from '@db-ux/ngx-core-components';
@Component({
// ...
imports: [
// ...,
DBButton
],
standalone: true
// ...
})<!-- app.component.html -->
<db-button variant="brand">Button</db-button>Events
There are 3 ways to use Events in Angular:
<db-input
label="Inputfield"
name="input-name"
[(ngModel)]="inputModel"
></db-input><db-input
label="Inputfield"
name="input-name"
[formControl]="inputControl"
></db-input><db-input
label="Inputfield"
name="input-name"
(change)="inputModel = $event.target.value"
></db-input>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-cliThis 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 Angular templates, we provide the @db-ux/core-eslint-plugin ESLint plugin.
Installation
pnpm add eslint @db-ux/core-eslint-plugin @angular-eslint/template-parser --save-devSetup
// eslint.config.js
import dbUx from "@db-ux/core-eslint-plugin";
import angularTemplateParser from "@angular-eslint/template-parser";
export default [
{
files: ["**/*.html"],
languageOptions: {
parser: angularTemplateParser
},
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-devSetup
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.
