Getting Started with code | VUE (Single Bundle)
The @dhl-official/vue-library-single-bundle npm package is designed to provide the DHL User Interface Library components ready to be used in a vue application. It delivers a single bundle JavaScript file that contains all the necessary components.
It is important to note that the package does not provide a lazy loading feature. This means that all the components included in the bundle will be loaded upfront when the application starts. While this ensures that all the components are readily available for use, it may result in a larger initial bundle size and potentially slower loading times.
If lazy loading is a requirement for your application, you may consider using @dhl-official/vue-library.
Overall, the @dhl-official/vue-library-single-bundle package provides a convenient way to access and utilize the DHL User Interface Library components in a Vue application, but it does not include a built-in lazy loading feature.
Install
- npm
- Yarn
- pnpm
- Bun
npm install @dhl-official/vue-library-single-bundle
yarn add @dhl-official/vue-library-single-bundle
pnpm add @dhl-official/vue-library-single-bundle
bun add @dhl-official/vue-library-single-bundle
Add styles and initialize DUIL
Update your application entry point to import the DUIL styles and run the global DUIL setup before mounting the Vue application:
Due to a Stencil issue, the global setup must currently be run manually when using the single-bundle package.
import { createApp } from 'vue';
import App from './App.vue';
import '@dhl-official/tokens/index.css';
import { initDUIL } from '@dhl-official/stencil-library';
await initDUIL();
createApp(App).mount('#app');
Use DUIL components
Import each Vue component that you use. Importing a wrapper also registers its underlying custom element, so no plugin or manual custom-element registration is required. Components imported with PascalCase can also be written in kebab-case in the template:
<script setup>
import { DhlAlert, DhlButton } from '@dhl-official/vue-library-single-bundle';
</script>
<template>
<duil310-dhl-button>Button</duil310-dhl-button>
<duil310-dhl-alert body-text="Your shipment is on its way."></duil310-dhl-alert>
</template>
The public duil310-dhl-* tags are Vue component wrappers, so they should not be added
to Vue's compilerOptions.isCustomElement configuration.
Known issues
When using a web component directly instead of its Vue wrapper, some values must
be passed as DOM properties with Vue's .prop modifier. See Vue's
web components documentation
for more information.
Want to avoid invalid prop values?
Use the type-safe constants for consistent and reliable prop values. Learn more