Native Web Components playground

Nova v3.38.0

Preview

Web Components

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
  • 2 npm packages
  • 5 steps to your first component

New to Nova? Read Getting Started

Install Nova's native Web Components in plain HTML, JavaScript, or TypeScript without a framework, configure Tailwind CSS v4 with a Nova theme, and render your first component.

1. Install packages#

Install the Web Components package and the base tokens/plugin package:

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

Or with Yarn:

bashyarn add @nova-design-system/nova-webcomponents @nova-design-system/nova-base
Elia developer VMs

If you encounter SSL certificate errors on a developer VM, run npm config set strict-ssl false as documented in the Developer Setup guide.

2. Set up Tailwind CSS and themes#

Nova Web Components rely on Tailwind CSS v4 for layout, spacing, and utility classes. The CSS-only Nova plugin binds Nova design tokens to Tailwind utilities with no JavaScript config file.

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

Install Tailwind CSS and the Vite plugin#

bashnpm install -D tailwindcss @tailwindcss/vite
Tip

Install the Tailwind CSS IntelliSense VS Code extension for autocomplete across Tailwind and Nova design tokens.

Configure vite.config.ts#

tsimport { defineConfig } from 'vite';
import tailwindcss from '@tailwindcss/vite';

export default defineConfig({
  plugins: [tailwindcss()],
});

Import Tailwind, the Nova plugin, and one theme#

Create a global CSS file (for example src/index.css) and 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. */

Do not combine theme/plugin.css with @nova-design-system/nova-base/dist/css/nova-utils.css.

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/index.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 custom elements#

Import your stylesheet and register Nova's custom elements in your entry script (for example src/main.ts):

tsimport './index.css';
import { defineCustomElements } from '@nova-design-system/nova-webcomponents/loader';

defineCustomElements();

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/index.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#

Use nv-* elements directly in HTML alongside Tailwind utilities, and attach listeners to Nova custom events such as valueChanged:

html<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Nova Web Components</title>
    <script type="module" src="/src/main.ts"></script>
  </head>
  <body class="bg-level-10 text-high p-6">
    <main class="flex max-w-md flex-col gap-4">
      <nv-fieldtext id="name" label="Name" placeholder="Enter your name"></nv-fieldtext>
      <nv-button id="greet" emphasis="high">Say hello</nv-button>
      <nv-alert id="output" feedback="information" hidden></nv-alert>
    </main>

    <script type="module">
      const field = document.getElementById('name');
      const button = document.getElementById('greet');
      const output = document.getElementById('output');

      let currentName = '';
      field.addEventListener('valueChanged', (event) => {
        currentName = event.detail ?? '';
      });

      button.addEventListener('click', () => {
        output.heading = currentName ? `Hello, ${currentName}.` : 'Hello from Nova.';
        output.hidden = false;
      });
    </script>
  </body>
</html>

Working with slots#

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

html<nv-button emphasis="medium">
  <nv-icon name="download" slot="leading-icon" aria-hidden="true"></nv-icon>
  Export report
  <nv-icon name="arrow-right" slot="trailing-icon" aria-hidden="true"></nv-icon>
</nv-button>

Next steps#