# Create a new application by executing:
npm create vue@latest
# Follow the installation wizard to set everything up:
✔ Project name (target directory): "./my-app"
✔ Select features to include in your project:
◼ TypeScript "Yes"
◼ JSX Support "Yes"
◼ Router (SPA development) "Yes"
◼ Pinia (state management) "Yes"
◼ Vitest (unit testing) "Yes"
◼ End-to-End Testing "Yes"
◼ ESLint (error prevention) "Yes"
◼ Prettier (code formatting) "Yes"
✔ Select an End-to-End testing framework: "Playwright"
✔ Select experimental features to include in your project:
◻ Oxlint (experimental) "No"
◻ rolldown-vite "No"
✔ Skip all example code and start with a blank Vue project? "No"
npm install @porsche-design-system/components-vue
<PorscheDesignSystemProvider />.// src/App.vue
<script setup lang="ts">
import { RouterView } from 'vue-router';
+ import { PorscheDesignSystemProvider } from '@porsche-design-system/components-vue';
</script>
<template>
+ <PorscheDesignSystemProvider>
<header>…</header>
<RouterView />
+ </PorscheDesignSystemProvider>
</template>
/cn import instead, see
/* src/assets/main.css */
+ @import '@porsche-design-system/components-vue';
lightningcss polyfill for the light-dark() CSS function since it's broken.
// vite.config.ts
+ import { Features } from 'lightningcss';
export default defineConfig({
+ css: {
+ transformer: 'lightningcss',
+ // disables light-dark() polyfill of lightningcss which is broken https://github.com/porsche-design-system/porsche-design-system/issues/4257
+ lightningcss: {
+ exclude: Features.LightDark,
+ },
+ },
});
:defined.hydrated:defined
pseudo-class, scope the style to specific tags instead (e.g., :is(p-button, p-accordion, …):not(:defined)). See
/* src/assets/main.css */
@import '@porsche-design-system/components-vue';
+ :not(:defined) {
+ visibility: hidden;
+ }
<head> section of your HTML to preload fonts, icons, and component chunks.// vite.config.ts
import { defineConfig } from 'vite';
+ import {
+ getComponentChunkLinks,
+ getFontLinks,
+ getIconLinks,
+ getMetaTagsAndIconLinks,
+ } from '@porsche-design-system/components-vue/partials';
const transformIndexHtmlPlugin = () => {
return {
name: 'html-transform',
transformIndexHtml(html: string) {
+ const headPartials = [
+ // preloads fonts
+ getFontLinks(),
+ // preloads icons
+ getIconLinks(),
+ // preloads components
+ getComponentChunkLinks(),
+ // injects favicon, apple touch icons, android touch icons, etc.
+ getMetaTagsAndIconLinks({ appTitle: 'Porsche' }),
+ ].join('');
+ return html.replace(/<\/head>/, `${headPartials}$&`);
},
};
};
export default defineConfig({
plugins: [vue(), vueJsx(), vueDevTools(), transformIndexHtmlPlugin()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
});
npm install tailwindcss @tailwindcss/vite
// vite.config.ts
import { defineConfig } from 'vite';
+ import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
+ plugins: [vue(), vueJsx(), vueDevTools(), transformIndexHtmlPlugin(), tailwindcss()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
});
/* src/assets/main.css */
@import '@porsche-design-system/components-vue';
+ @import 'tailwindcss';
+ @import '@porsche-design-system/components-vue/tailwindcss';
<PWordmark />) with some Tailwind CSS styles. Then, run npm run dev and
verify that the component and styles display correctly.// src/App.vue
<script setup lang="ts">
import { RouterView } from 'vue-router'
import { PorscheDesignSystemProvider } from '@porsche-design-system/components-vue';
import { PWordmark } from '@porsche-design-system/components-vue';
</script>
<template>
<PorscheDesignSystemProvider>
<div class="grid justify-items-center col-span-full gap-fluid-md m-static-lg p-fluid-lg bg-surface rounded-lg">
<PWordmark />
<h1 class="prose-heading-4xl">Porsche Design System</h1>
</div>
<header>…</header>
<RouterView />
</PorscheDesignSystemProvider>
</template>
<style scoped>
…
</style>
