@db-ux/v-core-components
v4.7.2
Published
Vue components for @db-ux/core-components
Readme
@db-ux/v-core-components
A Vue library containing all styles & components of DB UX Design System (technical components).
Note: Find more information about specific components here
Install
npm i @db-ux/v-core-componentsNote: This will install
@db-ux/core-foundationsand@db-ux/core-componentsas well which contains thecss/scssfiles
Styling Dependencies
Import the styles in scss or css. Based on your technology the file names could be different.
- Default (relative): points to
../assets - Rollup (rollup): points to
@db-ux/core-foundations/assets - Webpack (webpack): points to
~@db-ux/core-foundations/assets
// style.scss
@forward "@db-ux/core-components/build/styles/rollup";// main.ts
import "./style.scss";// main.ts
import "@db-ux/core-components/build/styles/rollup.css";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"))
}
}
});Note: The
@db-ux/core-components/build/styles/relativefile contains optional and all components styles. If you consider performance issues see @db-ux/core-components for more information.
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
<script setup lang="ts">
import { DBButton } from "@db-ux/v-core-components";
</script>
<template>
<DBButton icon="x_placeholder">Test</DBButton>
</template>Events
We add v-model support which fires on every change.
But you can use normal @ events as well.
Both Inputs in this example do the same:
<script setup lang="ts">
import { DbInput } from "@db-ux/v-core-components";
import { ref } from "vue";
const input = ref("");
</script>
<template>
<DBInput
label="Inputfield"
name="input-name"
v-model:value="input"
></DBInput>
<DBInput
label="Inputfield"
name="input-name"
:value="input"
@change="e => input = e.target.value"
></DBInput>
</template>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 Vue project, we provide the @db-ux/core-eslint-plugin ESLint plugin.
Installation
npm install eslint @db-ux/core-eslint-plugin vue-eslint-parser @typescript-eslint/parser --save-devSetup
// eslint.config.js
import dbUx from "@db-ux/core-eslint-plugin";
import vueParser from "vue-eslint-parser";
import tsParser from "@typescript-eslint/parser";
export default [
{
files: ["**/*.vue"],
languageOptions: {
parser: vueParser,
parserOptions: {
parser: tsParser,
ecmaVersion: "latest",
sourceType: "module"
}
},
plugins: {
"db-ux": dbUx
},
rules: dbUx.configs.recommended.rules
}
];📖 Learn more about @db-ux/core-eslint-plugin 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.
