React playground

Nova v3.38.0

Preview

React

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-react
  • 3 npm packages
  • 4 steps to your first component

New to Nova? Read Getting Started

Install Nova in a React application, configure Tailwind CSS v4 with a Nova theme, and render your first component.

Using Next.js?

Next.js requires dedicated Server and Client Component import paths. Follow Next.js Integration for App Router setup.

1. Install packages#

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

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

Or with Yarn:

bashyarn add @nova-design-system/nova-webcomponents @nova-design-system/nova-base @nova-design-system/nova-react @stencil/react-output-target
Yarn peer dependencies and Elia VMs
  • Yarn does not install peer dependencies automatically, so include @stencil/react-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 + React. For other bundlers, follow the Tailwind CSS installation guide and keep the stylesheet imports in step 3 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.

Add the plugin to vite.config.ts#

tsimport { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';

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

Import Tailwind, the Nova plugin, and one theme#

In your global stylesheet (for example src/index.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. */

Do not combine theme/plugin.css with @nova-design-system/nova-base/dist/css/nova-utils.css — Tailwind generates the utilities you use and avoids shipping redundant CSS.

Import the stylesheet from your application entry point (src/main.tsx):

tsximport { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import './index.css';
import App from './App.tsx';

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <App />
  </StrictMode>,
);

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. 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 your global 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" />

4. Render your first component#

Import components directly from @nova-design-system/nova-react and lay them out with Tailwind utilities:

tsximport { useState } from 'react';
import { NvAlert, NvButton, NvFieldtext } from '@nova-design-system/nova-react';

export default function App() {
  const [name, setName] = useState('');
  const [greeting, setGreeting] = useState('');

  return (
    <div className="flex max-w-md flex-col gap-4 p-6">
      <NvFieldtext
        label="Name"
        placeholder="Enter your name"
        value={name}
        onValueChanged={(event) => setName(event.detail)}
      />

      <NvButton
        emphasis="high"
        onClick={() =>
          setGreeting(name ? `Hello, ${name}.` : 'Hello from Nova.')
        }
      >
        Say hello
      </NvButton>

      {greeting && <NvAlert feedback="information" heading={greeting} />}
    </div>
  );
}

Working with slots#

Default slot content goes directly inside a component as React children. For named slots, add the slot attribute to the slotted element:

tsximport { NvButton, NvIcon } from '@nova-design-system/nova-react';

export function ExportButton() {
  return (
    <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>
  );
}

Next steps#