Nova Components React provides an easy way to use Nova’s native Web Components within your React applications.
-
Nova Components React
- Key Features
- Installation
-
Setup Using Tailwind (Recommended)
- 1. Install Tailwind CSS and the Vite Plugin
- 2. Configure the Vite Plugin
- 3. Create
tailwind.config.ts
- 4. Configure Tailwind and Nova Plugin in
index.css
- 5. Include the Nova Tokens (Spark or Ocean)
- 6. Use Nova Components with Tailwind Utilities
- 7. Setup the Nova Font
- Creating Your Own Style Components with Tailwind
- Setup Without Tailwind (Not Recommended)
- Nova Font Pro Integration
- Lightweight Integration: Leverage Nova Web Components with minimal configuration in React.
- Customizable Styling: Use Tailwind (recommended) or Nova’s utility classes to quickly style components.
-
Dark Mode Ready: Toggle dark mode by adding the
dark
class to yourbody
element. - Nova Font Pro Support: Easily integrate Nova’s custom font for a consistent design experience.
Install the necessary packages using the package manager of your choice:
npm install @nova-design-system/nova-webcomponents @nova-design-system/nova-base @nova-design-system/nova-react
or
yarn add @nova-design-system/nova-webcomponents @nova-design-system/nova-base @nova-design-system/nova-react
Note for Yarn Users Yarn does not automatically install peer dependencies. You must install the following peer dependency manually:
yarn add @stencil/react-output-target
We highly recommend using Tailwind CSS for styling, as it ensures an optimized bundle size and a powerful utility-first workflow. Nova offers a dedicated Tailwind plugin and theme, allowing you to seamlessly integrate Nova’s design tokens with Tailwind’s utility classes for a consistent and efficient styling workflow.
Tailwind Version This guide is written for Tailwind v4. While compatible with v3, some features may not work as expected.
Below is an example setup using Vite + React. If you’re using another framework or bundler, please refer to the Tailwind Installation Guide.
npm install tailwindcss @tailwindcss/vite
Use the Tailwind CSS IntelliSense Extension to get full autocomplete support for Tailwind and Nova tokens.
Add the tailwindcss plugin to your vite.config.ts
:
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
tailwindcss(),
],
})
In the root of your project, create a tailwind.config.ts
(or .js
) file and include the Nova theme:
import type { Config } from 'tailwindcss'
import { novaTailwindTheme } from "@nova-design-system/nova-base/theme"
export default {
theme: novaTailwindTheme,
} satisfies Config
@import 'tailwindcss';
@config "../tailwind.config.ts";
@plugin "@nova-design-system/nova-base/theme/plugin";
@custom-variant dark (&:where(.dark, .dark *));
Dark Mode To enable dark mode, add the
dark
class to the<body>
element.
In your main entry point (main.tsx
or index.tsx
), import one of the Nova tokens CSS files:
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import "@nova-design-system/nova-base/dist/css/spark.css"; // or ocean.css
import './index.css'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>
)
import { useState } from 'react'
import { NvButton } from "@nova-design-system/nova-react"
const MyComponent: React.FC = () => {
const [count, setCount] = useState(0)
return (
<div className="flex items-center justify-center">
<NvButton danger onClick={() => setCount(count + 1)}>
Count is {count}
</NvButton>
</div>
)
}
export default MyComponent
Follow the steps in the Nova Font Pro Integration section below.
If you find you’re repeating the same set of utility classes for certain UI elements (e.g., a card component), you can group them using Tailwind’s @apply
keyword:
/* any css file */
.card {
@apply bg-gray-50 dark:bg-gray-500 p-4 rounded-md shadow-sm;
}
Then in your markup, instead of:
<div className="bg-gray-50 dark:bg-gray-500 p-4 rounded-md shadow-sm">
{/* Content */}
</div>
<div className="bg-gray-50 dark:bg-gray-500 p-4 rounded-md shadow-sm">
{/* Content */}
</div>
You can use your new card
class:
<div className="card">
{/* Content */}
</div>
<div className="card">
{/* Content */}
</div>
This ensures consistent styling and keeps your markup clean. Any colors or spacing used will reference the correct Nova Tokens.
If you don’t plan to use Tailwind, Nova provides a large utility CSS file for quick prototyping. Be aware that this approach will increase your CSS bundle size, offer less options, and lacks the flexibility and optimizations of Tailwind.
In your entry point (main.tsx
):
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import '@nova-design-system/nova-base/dist/css/spark.css' // or ocean.css
import '@nova-design-system/nova-base/dist/css/nova-utils.css'
import './index.css'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>
)
import { useState } from 'react'
import { NvButton } from "@nova-design-system/nova-react"
const MyComponent: React.FC = () => {
const [count, setCount] = useState(0)
return (
<div className="flex items-center justify-center">
<NvButton danger onClick={() => setCount(count + 1)}>
Count is {count}
</NvButton>
</div>
)
}
export default MyComponent
[!WARNING] Nova Fonts is a protected asset and is not included in the Nova Base package. You need to include the Nova Fonts CSS file in your project. To get the Nova Fonts URL, please contact us via Teams or get the URL in the Nova Design System internal wiki.
Once you have the URL, you can integrate it using any of these methods:
In your main CSS file (e.g., src/index.css
):
@import url('https://novaassets.azureedge.net/fonts/nova-fonts-pro.css');
In your index.html
:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://novaassets.azureedge.net/fonts/nova-fonts-pro.css">
</head>
<body>
<div id="root"></div>
</body>
</html>
The nova-fonts-pro.css
file includes both font definitions and the font-family
rule for the body
, automatically applying the fonts across your React application.