Vue playground

Nova v3.38.0

Preview

Vue

Installation

Install Nova, configure Tailwind CSS and themes, and render your first component.

npm install @nova-design-system/nova-webcomponents @nova-design-system/nova-base @nova-design-system/nova-vue
  • Vue 3
  • ES2022+ build target
  • 3 npm packages
  • 5 steps to your first component

New to Nova? Read Getting Started

Install Nova in a Vue 3 application, configure Tailwind CSS v4 with a Nova theme, register the Vue plugin, and render your first component.

Requirements#

  • Vue 3
  • ES2022+ build target — the Nova Vue plugin uses top-level await so Stencil custom elements are registered before Vue mounts. In Vite, set build: { target: 'es2022' } in vite.config.ts.

1. Install packages#

Install the web components core, the base tokens/plugin package, and the Vue wrapper:

bashnpm install @nova-design-system/nova-webcomponents @nova-design-system/nova-base @nova-design-system/nova-vue

Or with Yarn:

bashyarn add @nova-design-system/nova-webcomponents @nova-design-system/nova-base @nova-design-system/nova-vue @stencil/vue-output-target
Yarn peer dependencies and Elia VMs
  • Yarn does not install peer dependencies automatically, so include @stencil/vue-output-target when using Yarn.
  • On Elia developer VMs experiencing SSL certificate errors, run npm config set strict-ssl false as documented in the Developer Setup guide.

2. Set up Tailwind CSS and themes#

Nova uses Tailwind CSS v4 as its styling layer. The CSS-only Nova plugin maps Nova design tokens to Tailwind utilities and requires no JavaScript config file.

This walkthrough uses Vite + Vue. For Nuxt or other bundlers, follow the Tailwind CSS installation guide and keep the stylesheet imports below.

Install Tailwind CSS and the Vite plugin#

bashnpm install tailwindcss @tailwindcss/vite
Tip

Install the Tailwind CSS IntelliSense VS Code extension for autocomplete across Tailwind and Nova design tokens. For Vue TypeScript and IntelliSense support, use the Vue - Official extension.

Configure vite.config.ts#

Add the tailwindcss() plugin and set the build target to es2022:

tsimport { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import tailwindcss from '@tailwindcss/vite';

export default defineConfig({
  plugins: [vue(), tailwindcss()],
  build: {
    target: 'es2022',
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
});

Import Tailwind, the Nova plugin, and one theme#

In your main stylesheet (for example src/assets/main.css), import Tailwind, Nova's CSS-only plugin, and exactly one token theme (spark.css or ocean.css):

css@import 'tailwindcss';
@import '@nova-design-system/nova-base/theme/plugin.css';
@import '@nova-design-system/nova-base/dist/css/spark.css';
/* Or import ocean.css instead of spark.css. */

Remove any conflicting boilerplate CSS generated by create-vue, and do not import @nova-design-system/nova-base/dist/css/nova-utils.css alongside Tailwind.

Dark mode#

Enable dark mode by adding the dark class to <body> (or another root container). Semantic tokens such as bg-level-00 and text-high adapt automatically.

html<body class="dark">
Deprecated JavaScript Tailwind configuration

The previous JavaScript theme and plugin remain available for backward compatibility. Do not combine this setup with theme/plugin.css.

tailwind.config.ts:

tsimport type { Config } from 'tailwindcss';
import { novaTailwindTheme } from '@nova-design-system/nova-base/theme';

export default {
  theme: novaTailwindTheme,
} satisfies Config;

src/assets/main.css:

css@import 'tailwindcss';
@import '@nova-design-system/nova-base/dist/css/spark.css';

@config '../../tailwind.config.ts';
@plugin '@nova-design-system/nova-base/theme/plugin';
@custom-variant dark (&:where(.dark, .dark *));

3. Register the Nova Vue plugin#

Register NovaComponents in src/main.ts so Nova custom elements are defined before your application mounts:

tsimport './assets/main.css';

import { createApp } from 'vue';
import { NovaComponents } from '@nova-design-system/nova-vue/plugin';
import App from './App.vue';

const app = createApp(App);

app.use(NovaComponents);
app.mount('#app');

4. Add Nova Font Pro#

Protected asset

Nova Font Pro (TT Norms Pro) is a licensed Elia Group asset and is not bundled in @nova-design-system/nova-base. Get the stylesheet URL from the Nova internal wiki or ask the Nova team on Teams.

Import the font stylesheet in src/assets/main.css (recommended):

css@import url('contact-us-for-URL/nova-fonts-pro.css');

Or link it in index.html:

html<link rel="stylesheet" href="contact-us-for-URL/nova-fonts-pro.css" />

5. Render your first component#

Import components from @nova-design-system/nova-vue, bind values with v-model, and style layouts with Tailwind utilities:

vue<script setup lang="ts">
import { ref } from 'vue';
import { NvAlert, NvButton, NvFieldtext } from '@nova-design-system/nova-vue';

const name = ref('');
const greeting = ref('');

function greet() {
  greeting.value = name.value ? `Hello, ${name.value}.` : 'Hello from Nova.';
}
</script>

<template>
  <div class="flex max-w-md flex-col gap-4 p-6">
    <NvFieldtext
      v-model="name"
      label="Name"
      placeholder="Enter your name"
    />

    <NvButton emphasis="high" @click="greet">
      Say hello
    </NvButton>

    <NvAlert v-if="greeting" feedback="information" :heading="greeting" />
  </div>
</template>

Working with slots#

Place default slot content directly inside a component. For named slots, add the slot attribute to the slotted element:

vue<template>
  <NvButton emphasis="medium">
    <NvIcon name="download" slot="leading-icon" aria-hidden="true" />
    Export report
    <NvIcon name="arrow-right" slot="trailing-icon" aria-hidden="true" />
  </NvButton>
</template>

Next steps#