Styling and Tailwind Guide for Nova React
Introduction
This guide focuses on practical Tailwind CSS usage with Nova components. As an Elia Group developer, you'll use Nova components as your foundation—most of your Tailwind work will involve layout, spacing, and composition rather than building components from scratch.
Key Principle: Nova handles component design. You handle page layout, spacing, and organization using Tailwind utilities.
Prerequisites
Before following this guide, ensure you have completed the Nova React setup including Tailwind configuration.
Quick checklist:
- ✅ Tailwind CSS v4 installed and configured
- ✅ Nova CSS plugin imported in
index.css - ✅ Exactly one design-token theme (
spark.cssorocean.css) imported in the same stylesheet - ✅ VS Code Tailwind IntelliSense extension installed (recommended)
Existing projects can keep the deprecated JavaScript setup documented in the Nova React README, but it must not be combined with theme/plugin.css.
Core Concepts
1. Nova Components + Tailwind Layout
Nova provides pre-styled, accessible components. Your job is to position and space them on the page.
import { NvButton } from "@nova-design-system/nova-react";
function Dashboard() {
return (
<div className="min-h-screen bg-level-10 p-6">
<div className="max-w-7xl mx-auto space-y-6">
<h1 className="typo-heading-lg-bold text-high">Dashboard</h1>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
<div className="bg-level-00 rounded-lg shadow p-6">
<h2 className="typo-heading-sm-medium mb-4">Total Users</h2>
<p className="typo-text-xl-bold text-high">1,234</p>
</div>
<div className="bg-level-00 rounded-lg shadow p-6">
<h2 className="typo-heading-sm-medium mb-4">Active Sessions</h2>
<p className="typo-text-xl-bold text-high">567</p>
</div>
<div className="bg-level-00 rounded-lg shadow p-6">
<h2 className="typo-heading-sm-medium mb-4">Revenue</h2>
<p className="typo-text-xl-bold text-high">€89,000</p>
</div>
</div>
</div>
</div>
);
}
What Tailwind does here:
min-h-screen- Full viewport heightbg-level-10- Background elevation (semantic token)p-6- Padding (24px)max-w-7xl mx-auto- Centered container with max widthspace-y-6- Vertical spacing between childrenbg-level-00 rounded-lg shadow- Card-like container styling with base elevationgrid grid-cols-1 md:grid-cols-3 gap-6- Responsive grid layout
2. Design Tokens Integration
Nova tokens are automatically available through Tailwind. The Nova CSS plugin maps tokens to Tailwind's theme system.
Color Tokens:
Nova uses an intentional token system that provides semantic meaning to colors. Always prefer intentional tokens over primitive color values.
📚 Learn more: Nova Design Tokens Documentation
Intentional Tokens (USE THESE FIRST):
// Text colors (semantic hierarchy)
<p className="text-high">Primary text with highest contrast</p>
<p className="text-medium">Secondary text with medium contrast</p>
<p className="text-low">Tertiary text with lower contrast</p>
<p className="text-disabled">Disabled or inactive text</p>
// Background elevations (layering system)
<div className="bg-level-00">Base level (cards, modals)</div>
<div className="bg-level-10">Elevated level (page background)</div>
<div className="bg-level-20">Higher elevation</div>
// Border colors (semantic hierarchy)
<div className="border border-low">Subtle border</div>
<div className="border border-medium">Standard border</div>
<div className="border border-high">Prominent border</div>
// Interactive states
<button className="bg-interactive hover:bg-interactive-hover active:bg-interactive-active">
Interactive element
</button>
// Feedback colors (alerts, notifications, form validation)
<div className="bg-feedback-success-low text-feedback-success-high">Success message</div>
<div className="bg-feedback-error-low text-feedback-error-high">Error message</div>
<div className="bg-feedback-warning-low text-feedback-warning-high">Warning message</div>
<div className="bg-feedback-information-low text-feedback-information-high">Info message</div>
Primitive Tokens (USE SPARINGLY - Only for specific design needs):
// Only use primitive colors for data visualization, charts, or when intentional tokens don't fit
<div className="bg-green-500">Chart bar</div>
<div className="bg-turquoise-500">Data point</div>
<div className="bg-crimson-500">Alert indicator</div>
Token Selection Guide:
| Use Case | Token to Use | ❌ Avoid |
|---|---|---|
| Page background | bg-level-10 | bg-gray-50 |
| Card/modal background | bg-level-00 | bg-white |
| Primary text | text-high | text-gray-900 |
| Secondary text | text-medium | text-gray-600 |
| Subtle borders | border-low | border-gray-200 |
| Success state | bg-feedback-success-low text-feedback-success-high | bg-green-100 text-green-800 |
| Data visualization | bg-green-500, bg-turquoise-500 | OK to use primitives here |
Spacing Tokens:
Nova provides a consistent spacing scale based on a 4px grid system. All spacing utilities are multiples of 4px for visual harmony:
// Padding
<div className="p-2"> {/* 8px */}
<div className="p-4"> {/* 16px */}
<div className="p-6"> {/* 24px */}
<div className="p-8"> {/* 32px */}
// Margin
<div className="mt-4 mb-6"> {/* top: 16px, bottom: 24px */}
<div className="mx-auto"> {/* horizontal centering */}
// Gap (for flex/grid)
<div className="flex gap-4"> {/* 16px gap between items */}
<div className="grid gap-6"> {/* 24px gap between grid items */}
Common spacing values:
2(8px): Tight spacing, inline elements4(16px): Standard spacing, most common6(24px): Comfortable spacing, section gaps8(32px): Large spacing, major sections12(48px),16(64px),24(96px): Extra large gaps
Direction modifiers:
p-*: All sides paddingpx-*,py-*: Horizontal/vertical paddingpt-*,pr-*,pb-*,pl-*: Individual sides- Same pattern for margins (
m-*,mx-*, etc.)
Typography Tokens:
Nova provides semantic typography classes that combine font size, weight, and line height. Always use these instead of Tailwind's font utilities for consistency:
// Headings
<h1 className="typo-heading-xl-bold">Main Title</h1>
<h2 className="typo-heading-lg-medium">Section Title</h2>
<h3 className="typo-heading-md-medium">Subsection</h3>
// Body text
<p className="typo-text-md-regular">Regular paragraph text</p>
<span className="typo-text-sm-medium">Label or emphasis</span>
// Code/mono
<code className="typo-mono-sm-regular">npm install</code>
Naming pattern: typo-[usage]-[size]-[weight]
- Usage:
heading,text,mono - Size:
xs,sm,md,lg,xl - Weight:
regular,medium,bold
When to use:
- Headings: Page titles, section headers, card titles
- Text: Paragraphs, descriptions, labels, UI text
- Mono: Code snippets, technical data, fixed-width content
Border Radius:
Nova provides a comprehensive border radius scale mapped to Tailwind utilities:
// No rounding
<div className="rounded-none"> {/* 0px */}
// Small radius
<div className="rounded-sm"> {/* 2px */}
// Default radius
<div className="rounded"> {/* 4px - most common for cards, buttons */}
// Medium radius
<div className="rounded-md"> {/* 6px */}
// Large radius
<div className="rounded-lg"> {/* 8px - good for larger cards */}
// Extra large radius
<div className="rounded-xl"> {/* 12px */}
// 2X large radius
<div className="rounded-2xl"> {/* 16px */}
// 3X large radius
<div className="rounded-3xl"> {/* 24px */}
// Fully rounded (circular)
<div className="rounded-full"> {/* 9999px - avatars, badges */}
// Apply to specific corners
<div className="rounded-t-lg rounded-b-none"> {/* top: 8px, bottom: 0 */}
<div className="rounded-l-md rounded-r-xl"> {/* left: 6px, right: 12px */}
Common usage:
- Cards and containers:
roundedorrounded-lg - Buttons: handled by Nova components
- Avatars and badges:
rounded-full - Images:
rounded-mdorrounded-lg
Common Layout Patterns
These proven layout patterns solve common UI challenges in enterprise applications. Master these foundational patterns to build consistent, responsive interfaces efficiently. Each pattern uses Tailwind's flex and grid utilities combined with Nova's spacing tokens.
🎮 New to Flexbox and Grid? Learn by playing these interactive games:
- Flexbox Froggy - Learn flexbox by helping Froggy and friends
- Grid Garden - Learn CSS Grid by watering your garden
Container and Page Layout
Centered page containers with max-width constraints provide optimal reading length and consistent alignment across screen sizes. Use this pattern as the foundation for most page layouts:
Best for: Main content areas, form pages, article layouts, dashboards
function Page() {
return (
<div className="min-h-screen bg-gray-50">
{/* Main content container */}
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<h1 className="typo-heading-xl-bold mb-6">Page Title</h1>
{/* Content */}
</div>
</div>
);
}
Flexbox Layouts
Flexbox is your primary tool for one-dimensional layouts—arranging items in a row or column. Use flex for navigation bars, button groups, form fields, and any content that needs flexible alignment or distribution.
Key utilities: flex, items-center, justify-between, gap-*, flex-col
Horizontal layout:
<div className="flex items-center gap-4">
<NvButton>Cancel</NvButton>
<NvButton emphasis="high">Save</NvButton>
</div>
Vertical stack:
<div className="flex flex-col gap-4">
<NvFieldtext label="First Name" />
<NvFieldtext label="Last Name" />
<NvFieldtext label="Email" />
</div>
Space between items:
<div className="flex items-center justify-between">
<h2 className="typo-heading-md-bold">Users</h2>
<NvButton>Add User</NvButton>
</div>
Centered content:
<div className="flex items-center justify-center min-h-screen">
<div className="bg-white rounded-lg shadow-lg p-8 w-full max-w-md">
<h2 className="typo-heading-lg-bold mb-6">Login</h2>
{/* Form fields */}
</div>
</div>
Grid Layouts
CSS Grid excels at two-dimensional layouts with rows and columns. Use grid for card galleries, data dashboards, sidebar layouts, and any content requiring precise alignment in both directions.
Key utilities: grid, grid-cols-*, gap-*, col-span-*
Responsive pattern: grid-cols-1 md:grid-cols-2 lg:grid-cols-3 (mobile-first)
Responsive columns:
{/* 1 column on mobile, 2 on tablet, 3 on desktop */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<div className="bg-level-00 rounded-lg shadow p-4">Card 1</div>
<div className="bg-level-00 rounded-lg shadow p-4">Card 2</div>
<div className="bg-level-00 rounded-lg shadow p-4">Card 3</div>
</div>
Sidebar layout:
<div className="grid grid-cols-12 gap-6">
{/* Sidebar - 3 columns on desktop */}
<aside className="col-span-12 lg:col-span-3">
<div className="bg-level-00 rounded-lg shadow p-4">Navigation</div>
</aside>
{/* Main content - 9 columns on desktop */}
<main className="col-span-12 lg:col-span-9">
<div className="bg-level-00 rounded-lg shadow p-6">Main content</div>
</main>
</div>
Form grid:
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<NvFieldtext label="First Name" />
<NvFieldtext label="Last Name" />
<NvFieldtext label="Email" className="sm:col-span-2" />
<NvFieldtext label="Phone" />
<NvFieldtext label="Company" />
</div>
Spacing Utilities
Proper spacing creates visual hierarchy and improves readability. Tailwind offers two approaches: space-* for uniform spacing between children (best for lists), and individual margin/padding utilities for precise control.
Choose space-y-* / space-x-* when: All siblings need equal spacing (lists, menus, stacked content)
Choose mt-* / mb-* when: Specific elements need custom spacing
Consistent spacing with space-*:
{/* Vertical spacing */}
<div className="space-y-4">
<p>Paragraph 1</p>
<p>Paragraph 2</p>
<p>Paragraph 3</p>
</div>
{/* Horizontal spacing */}
<div className="flex space-x-2">
<NvButton>Edit</NvButton>
<NvButton>Delete</NvButton>
<NvButton>Share</NvButton>
</div>
Individual spacing:
<div className="mt-8 mb-6 px-4">
{/* margin-top: 32px, margin-bottom: 24px, padding-x: 16px */}
</div>
Customizing Nova Components
Nova components are designed to work seamlessly with Tailwind utilities. While components handle their internal styling, you control their position, spacing, and responsive behavior through the className prop. This section shows you how to extend Nova components without breaking their design.
Key principle: Add layout and spacing utilities; avoid overriding component internals (padding, colors, borders) which may cause conflicts.
Adding Classes to Components
Every Nova component accepts a className prop for adding Tailwind utilities. Use this for layout positioning, margins, widths, and responsive behavior:
Nova components accept a className prop for customization:
{/* Add margin using className */}
<NvButton className="mt-4">
Button with Margin
</NvButton>
{/* Use component props for component-specific features */}
<NvButton fluid>
Full Width Button (use 'fluid' prop, not 'w-full' class)
</NvButton>
{/* Adjust card spacing and background */}
<div className="bg-level-00 rounded-lg shadow-lg p-8">
Custom Card Content
</div>
Styling Slotted Content
Many Nova components accept children or slotted content. You have full control over the styling of content you place inside components using standard HTML elements and Tailwind classes:
{/* Simple text with custom styling */}
<NvButton emphasis="high">
<span className="typo-text-md-medium">Save Changes</span>
</NvButton>
{/* Complex content with icons */}
<NvButton>
<span className="flex items-center gap-2">
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
<path d="M7.707 10.293a1 1 0 10-1.414 1.414l3 3a1 1 0 001.414 0l3-3a1 1 0 00-1.414-1.414L11 11.586V6h5a2 2 0 012 2v7a2 2 0 01-2 2H4a2 2 0 01-2-2V8a2 2 0 012-2h5v5.586l-1.293-1.293zM9 4a1 1 0 012 0v2H9V4z" />
</svg>
<span className="typo-text-sm-medium">Download</span>
</span>
</NvButton>
{/* For layout control, wrap the button instead of overriding its classes */}
<div className="px-8">
<NvButton>Centered Button</NvButton>
</div>
⚠️ Important: Avoid overriding component internals like padding (px-*, py-*) directly on Nova components. Use wrapper elements for layout control instead.
Conditional Styling
Dynamic UI often requires different styles based on state or props. Use template literals or conditional class logic to apply different Tailwind utilities based on your data:
⚠️ Critical: Never Build Class Names Dynamically
Tailwind scans your source files for complete class names at build time. Dynamic class construction breaks this:
{/* ❌ WRONG - These classes won't be generated */}
<div className={`text-${color}-500`}>Won't work</div>
<div className={`bg-${theme}-${shade}`}>Won't work</div>
<p className={isLarge ? 'text-lg' : `text-${size}`}>Won't work</p>
{/* ✅ CORRECT - Use complete class names */}
<div className={color === 'red' ? 'text-red-500' : 'text-blue-500'}>Works!</div>
<div className={theme === 'dark' ? 'bg-gray-900' : 'bg-white'}>Works!</div>
<p className={isLarge ? 'text-lg' : 'text-sm'}>Works!</p>
📚 Learn more: Tailwind - Dynamic Class Names
Proper conditional styling:
function StatusBadge({ status }: { status: 'active' | 'inactive' }) {
return (
<span
className={`
inline-block px-3 py-1 rounded-full typo-text-sm-medium
${status === 'active'
? 'bg-feedback-success-low text-feedback-success-high'
: 'bg-level-10 text-medium'
}
`}
>
{status}
</span>
);
}
Responsive Behavior
Tailwind's responsive prefixes (sm:, md:, lg:, xl:) let you adapt layouts to different screen sizes. Apply these to Nova components and containers to create mobile-first responsive interfaces:
Mobile-first approach: Base styles apply to mobile, then override for larger screens.
{/* Different layouts at different breakpoints */
<div className="
flex flex-col gap-4
md:flex-row md:items-center md:justify-between
">
<h2 className="typo-heading-lg-bold">Products</h2>
<NvButton emphasis="high">Add Product</NvButton>
</div>
{/* Responsive spacing */}
<div className="p-4 md:p-6 lg:p-8">
{/* padding increases with screen size */}
</div>
{/* Hide on mobile, show on desktop */}
<div className="hidden lg:block">
<div className="bg-level-00 rounded-lg shadow p-4">Desktop only sidebar</div>
</div>
Working with Forms
Forms benefit greatly from thoughtful layout and spacing. Use Tailwind to create clear visual hierarchy, group related fields, and provide proper spacing for labels, inputs, and actions. Nova form components integrate seamlessly with these patterns.
Form layout principles:
- Container max-width for readability (
max-w-2xl) - Consistent vertical spacing between fields (
space-y-4orspace-y-6) - Visual sections with borders to group related inputs
- Clear separation between form content and action buttons
Form Layout
A complete form with header, fields, and actions demonstrating best practices for spacing and grouping:
function UserForm() {
return (
<form className="max-w-2xl mx-auto space-y-6">
{/* Form header */}
<div className="border-b border-gray-200 pb-4">
<h2 className="typo-heading-lg-bold">Create User</h2>
<p className="typo-text-sm-regular text-gray-600 mt-2">
Fill in the user details below
</p>
</div>
{/* Form fields */}
<div className="space-y-4">
<NvFieldtext
label="Full Name"
placeholder="Enter full name"
required
/>
<NvFieldtext
type="email"
label="Email Address"
placeholder="user@example.com"
required
/>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<NvFieldtext label="Phone" placeholder="+32 123 45 67 89" />
<NvFieldtext label="Department" placeholder="Engineering" />
</div>
<NvTextarea
label="Notes"
placeholder="Additional information..."
rows={4}
/>
</div>
{/* Form actions */}
<div className="flex items-center justify-end gap-3 pt-4 border-t border-gray-200">
<NvButton type="button">Cancel</NvButton>
<NvButton type="submit" emphasis="high">Create User</NvButton>
</div>
</form>
);
}
Inline Form Elements
For search bars, filters, or quick actions, combine form fields with buttons horizontally. Use flex-1 on the input container to make it grow, and items-end to align the button with the input:
<div className="flex items-end gap-4">
<div className="flex-1">
<NvFieldtext label="Search" placeholder="Search users..." />
</div>
<NvButton emphasis="high">Search</NvButton>
</div>
Dark Mode Support
Nova's semantic tokens automatically adapt to dark mode, so when you use intentional tokens like bg-level-00, text-high, or border-low, they'll change appropriately when dark mode is active.
Key insight: If you're using semantic/intentional tokens throughout your app, dark mode support is built-in. You only need explicit dark: utilities when using primitive colors for specific purposes (like data visualization).
How it works: When .dark class is present on a parent, Nova's semantic tokens adapt automatically, and any dark:* utilities you've added will activate.
Best practice: Nova components and semantic tokens handle dark mode automatically. Only add explicit dark: variants when using primitive colors for special cases.
Using Semantic Tokens for Dark Mode
When using semantic tokens, dark mode adaptation is automatic:
{/* These adapt automatically - no dark: variants needed! */}
<div className="bg-level-00">
<h1 className="text-high typo-heading-lg-bold">Title</h1>
<p className="text-medium typo-text-md-regular">
Description text that automatically adapts to dark mode
</p>
</div>
If you must use primitive colors (e.g., for data visualization), add explicit dark variants:
{/* Only when using primitive colors */}
<div className="bg-green-500 dark:bg-green-700">
<span className="text-white">Chart element</span>
</div>
Dark Mode for Cards and Containers
With semantic tokens, your cards automatically adapt to dark mode:
{/* Semantic tokens handle dark mode automatically */}
<div className="bg-level-00 rounded-lg shadow border border-low p-6">
<h2 className="typo-heading-md-bold text-high mb-4">Card Title</h2>
<p className="typo-text-md-regular text-medium">
Card content that automatically works in both light and dark mode
</p>
</div>
Result:
- Light mode: white background, dark text, light border
- Dark mode: dark background, light text, dark border
- All automatic - no
dark:variants needed!
Toggling Dark Mode
Implement a dark mode toggle by adding/removing the dark class on the document body. Store the preference in localStorage to persist across sessions:
function DarkModeToggle() {
const [isDark, setIsDark] = useState(false);
useEffect(() => {
if (isDark) {
document.body.classList.add('dark');
} else {
document.body.classList.remove('dark');
}
}, [isDark]);
return (
<NvButton onClick={() => setIsDark(!isDark)}>
{isDark ? 'Light Mode' : 'Dark Mode'}
</NvButton>
);
}
Complete Layout Examples
The following examples demonstrate complete, production-ready layouts with detailed inline documentation explaining every Tailwind class choice.
Example 1: Application Shell with Sidebar
This example shows a classic sidebar + main content layout pattern used in enterprise applications.
MainLayout.tsx:
import { useState, useEffect } from 'react';
import { useLocation, useNavigate, NavLink } from 'react-router-dom';
import { NvSidebar, NvSidebarlogo, NvSidebarcontent, NvSidebarnavitem, NvSidebarnavsubitem, NvBreadcrumbs, NvBreadcrumb, NvIcon } from '@nova-design-system/nova-react';
interface BreadcrumbItem {
label: string;
href?: string;
isCurrent?: boolean;
}
interface TabItem {
label: string;
icon: string;
url: string;
}
interface PageState {
breadcrumbs: BreadcrumbItem[];
tabs: TabItem[];
}
export default function MainLayout({ children }: { children: React.ReactNode }) {
const location = useLocation();
const [pageState, setPageState] = useState<PageState>({
breadcrumbs: [],
tabs: []
});
const isActive = (path: string) => {
if (path === '/') return location.pathname === '/';
return location.pathname === path;
};
const isActivePrefix = (prefix: string) => {
return location.pathname.startsWith(prefix);
};
const getTabClass = (url: string) => {
const active = location.pathname === url;
return active ? 'nv-link active' : 'nv-link';
};
{/* ============================================================================
TAILWIND LAYOUT GUIDE FOR EMS APPLICATION
============================================================================
This layout uses a classic "sidebar + main content" pattern.
The structure is:
┌─────────────────────────────────────────────────────────────┐
│ flex w-full (root container) │
│ ┌──────────┬────────────────────────────────────────────────┤
│ │ │ grow flex flex-col h-screen (main area) │
│ │ Sidebar │ ┌──────────────────────────────────────────┐ │
│ │ (fixed │ │ header (breadcrumbs + title + tabs) │ │
│ │ width) │ ├──────────────────────────────────────────┤ │
│ │ │ │ main > section > card (children here) │ │
│ │ │ │ │ │
│ │ │ └──────────────────────────────────────────┘ │
│ └──────────┴────────────────────────────────────────────────┘
└─────────────────────────────────────────────────────────────┘
============================================================================ */}
return (
{/* ROOT CONTAINER
─────────────────────────────────────────────────────────────────────────────
flex → Creates a flexbox container. Children (sidebar + main) will sit
side by side horizontally (default flex-direction is row).
w-full → Width 100%. Ensures the container spans the entire viewport width.
───────────────────────────────────────────────────────────────────────────── */}
<div className="flex w-full">
{/* SIDEBAR
The NvSidebar component has its own fixed width defined internally.
Because the main content uses "grow", the sidebar keeps its natural
width while main expands to fill remaining space. */}
<NvSidebar type="collapsible">
<NvSidebarlogo label="EMS" />
<NvSidebarcontent>
<NvSidebarnavitem icon="home" active={isActive('/')}>
<NavLink to="/">Home</NavLink>
</NvSidebarnavitem>
<NvSidebarnavitem icon="database" collapsible active={isActivePrefix('/acquisition')}>
Acquisition
<NvSidebarnavsubitem active={isActive('/acquisition/iccp')}>
<NavLink to="/acquisition/iccp">ICCP</NavLink>
</NvSidebarnavsubitem>
<NvSidebarnavsubitem active={isActive('/acquisition/rtu')}>
<NavLink to="/acquisition/rtu">RTU</NavLink>
</NvSidebarnavsubitem>
</NvSidebarnavitem>
<NvSidebarnavitem icon="layout-dashboard" active={isActive('/ems')}>
<NavLink to="/ems">EMS</NavLink>
</NvSidebarnavitem>
<NvSidebarnavitem icon="cpu" active={isActive('/hardware')}>
<NavLink to="/hardware">Hardware</NavLink>
</NvSidebarnavitem>
</NvSidebarcontent>
</NvSidebar>
{/* MAIN CONTENT AREA
─────────────────────────────────────────────────────────────────────────
grow → flex-grow: 1. This is the KEY class that makes main content
expand to fill all remaining horizontal space after sidebar.
Without this, main would only be as wide as its content.
flex → Makes this a flex container too (for its children).
flex-col → flex-direction: column. Children (header, main) stack vertically.
h-screen → height: 100vh. Takes full viewport height. Combined with
flex-col, this creates a full-height column layout.
───────────────────────────────────────────────────────────────────────── */}
<div className="grow flex flex-col h-screen">
{pageState.breadcrumbs.length > 0 && (
{/* HEADER SECTION
─────────────────────────────────────────────────────────────────
pt-10 → padding-top: 2.5rem (40px). Creates breathing room at
top of header. We only use pt (not p or py) because
we want specific control over each side's padding.
───────────────────────────────────────────────────────────────── */}
<header className="pt-10">
{/* BREADCRUMBS
─────────────────────────────────────────────────────────────
px-10 → padding-left and padding-right: 2.5rem (40px).
Horizontal padding aligns breadcrumbs with page content.
Using px (not p) so we don't add vertical padding.
───────────────────────────────────────────────────────────── */}
<NvBreadcrumbs className="px-10">
{pageState.breadcrumbs.map((crumb, index) => (
<NvBreadcrumb key={index} current={crumb.isCurrent}>
{crumb.href && !crumb.isCurrent ? (
<a href={crumb.href}>{crumb.label}</a>
) : (
<span>{crumb.label}</span>
)}
</NvBreadcrumb>
))}
</NvBreadcrumbs>
{/* PAGE TITLE
─────────────────────────────────────────────────────────────
pt-2 → padding-top: 0.5rem (8px). Small gap between
breadcrumbs and title. Keeps them visually grouped.
px-10 → Matches breadcrumbs horizontal padding for alignment.
pb-6 → padding-bottom: 1.5rem (24px). Larger gap below title
to separate it from content/tabs below.
WHY different padding values?
- pt-2 (small): Breadcrumbs and title are related, keep close
- pb-6 (large): Title and content are separate sections, more space
───────────────────────────────────────────────────────────── */}
<h2 className="pt-2 px-10 pb-6">
{pageState.breadcrumbs[pageState.breadcrumbs.length - 1].label}
</h2>
{pageState.tabs.length > 0 ? (
{/* TAB NAVIGATION BAR
─────────────────────────────────────────────────────────
nv-tabs → Nova design system class for tab styling.
bg-level-00 → Nova design system background color (base level).
Creates visual separation from content below.
───────────────────────────────────────────────────────── */}
<nav className="nv-tabs bg-level-00">
{/* TAB LIST
─────────────────────────────────────────────────────
flex → Arranges tabs horizontally in a row.
px-8 → padding-left/right: 2rem (32px). Slightly less
than px-10 used above because tabs have their
own internal padding. This creates visual balance.
───────────────────────────────────────────────────── */}
<ul className="flex px-8">
{pageState.tabs.map((tab, index) => (
<li key={index}>
<NavLink to={tab.url} className={getTabClass(tab.url)}>
<NvIcon name={tab.icon} size="md" />
{tab.label}
</NavLink>
</li>
))}
</ul>
</nav>
) : (
{/* DIVIDER (when no tabs)
─────────────────────────────────────────────────────────
border-b → border-bottom. Creates a horizontal line.
border-low → Nova design system border color (subtle).
WHY? When there are no tabs, we still want visual separation
between header and content. This thin line provides that
without taking up space like the tab bar would.
───────────────────────────────────────────────────────── */}
<div className="border-b border-low"></div>
)}
</header>
)}
{/* MAIN ELEMENT
─────────────────────────────────────────────────────────────────
flex → Creates flex container for the section inside.
grow → flex-grow: 1. Expands to fill remaining vertical space
after header. This is what makes the content area stretch
to fill the screen height.
w-full → width: 100%. Ensures main spans full width of parent.
───────────────────────────────────────────────────────────────── */}
<main className="flex grow w-full">
{/* CONTENT SECTION (the gray background area)
─────────────────────────────────────────────────────────────
p-8 → padding: 2rem (32px) on all sides. Creates gutter
around the white card container.
bg-level-10 → Nova design system elevated background (gray).
Creates contrast with the white card inside.
h-full → height: 100%. Fills parent height.
grow → Expands to fill available space.
WHY bg-level-10?
This gray background creates visual depth. The white card (level-00)
appears to "float" above it, creating a sense of hierarchy.
───────────────────────────────────────────────────────────── */}
<section className="p-8 bg-level-10 h-full grow">
{/* CARD CONTAINER (white box where page content lives)
─────────────────────────────────────────────────────────
bg-level-00 → Nova design system base background (white/light).
This is the "card" that contains page content.
rounded-lg → border-radius: 0.5rem (8px). Softens corners
for a modern, friendly appearance.
border → Adds a 1px border around the card.
border-low → Nova design system subtle border color.
Defines card edges without being harsh.
min-h-1/2 → min-height: 50%. Card is always at least half
the parent height, even with little content.
Prevents awkwardly small cards on empty pages.
WHY these choices together?
- White background + gray parent = visual elevation
- Rounded corners = modern UI convention
- Subtle border = defines edges without heavy visual weight
- min-h-1/2 = consistent appearance across pages
───────────────────────────────────────────────────────── */}
<div className="bg-level-00 rounded-lg border border-low min-h-1/2">
{children}
</div>
</section>
</main>
</div>
</div>
);
}
Key Takeaways from this Layout:
-
Nested Flex Containers: The root uses
flexfor horizontal layout (sidebar + main), while the main area usesflex flex-colfor vertical stacking (header + content). -
The
growClass is Essential:- On the main content area: makes it fill remaining space after sidebar
- On the content section: makes it expand vertically to fill available height
-
Padding Patterns:
pt-10,px-10on header elements for consistent alignmentp-8on section for uniform gutter around the card- Different values (
pt-2vspb-6) create visual hierarchy
-
Background Levels:
bg-level-10(gray) +bg-level-00(white) creates depth and card elevation
Example 2: Data Table Page with Toolbar
This example shows a common pattern for list/table pages with filters and actions.
UsersPage.tsx:
import { useState, useEffect } from 'react';
import { NvButton, NvFielddropdown, NvDatatable, NvIcon } from '@nova-design-system/nova-react';
interface DropdownOption {
label: string;
value: string;
}
export default function UsersPage() {
{/* ============================================================================
PAGE CONTENT LAYOUT PATTERNS
============================================================================
This page demonstrates common patterns for content inside the card container:
┌─────────────────────────────────────────────────────────────┐
│ TOOLBAR (p-6 border-b flex) │
│ ┌─────────────────────────────────┐ ┌─────────────────────┐ │
│ │ Filters (flex grow gap-4) │ │ Actions (flex gap-4)│ │
│ └─────────────────────────────────┘ └─────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ DATA TABLE (pb-4) │
│ │
└─────────────────────────────────────────────────────────────┘
============================================================================ */}
const departmentOptions: DropdownOption[] = [
{ label: 'Engineering', value: 'engineering' },
{ label: 'Marketing', value: 'marketing' },
{ label: 'Sales', value: 'sales' },
// ... other departments
];
const statusOptions: DropdownOption[] = [
{ label: 'Active', value: 'active' },
{ label: 'Inactive', value: 'inactive' },
{ label: 'Pending', value: 'pending' },
// ... other statuses
];
const columns = [
{ field: 'name', headerName: 'Full Name' },
{ field: 'email', headerName: 'Email Address' },
{ field: 'department', headerName: 'Department' },
{ field: 'age', headerName: 'Age' },
{ field: 'salary', headerName: 'Salary' },
];
const data = [
{
name: 'John Smith',
email: 'john.smith@company.com',
department: 'Engineering',
age: 32,
salary: 75000
},
{
name: 'Jane Doe',
email: 'jane.doe@company.com',
department: 'Marketing',
age: 28,
salary: 60000
},
// ... more data
];
return (
<>
{/* TOOLBAR ROW
─────────────────────────────────────────────────────────────────────────────
p-6 → padding: 1.5rem (24px) on all sides. Consistent inner spacing
that matches the card's visual style.
border-b → border-bottom: 1px solid. Creates horizontal separator below toolbar.
border-low → Nova design system subtle border color.
flex → display: flex. Children arranged horizontally in a row.
PATTERN: Toolbar with left-aligned filters and right-aligned actions.
We achieve this by having two flex children:
1. Left group with "grow" → expands to push right group to the edge
2. Right group without grow → stays at its natural width on the right
───────────────────────────────────────────────────────────────────────────── */}
<div className="p-6 border-b border-low flex">
{/* LEFT GROUP: FILTERS
─────────────────────────────────────────────────────────────────────────
flex → Children (dropdowns, button) arranged horizontally.
grow → flex-grow: 1. THIS IS THE KEY! This group expands to fill
available space, pushing the right group (actions) to the edge.
Without this, both groups would sit on the left.
gap-4 → gap: 1rem (16px) between children. Creates consistent spacing
between filter controls without using margins on each element.
WHY gap instead of margins?
- gap only adds space BETWEEN items, not before first or after last
- Easier to maintain: change one value instead of margins on each child
- Works automatically when adding/removing children
───────────────────────────────────────────────────────────────────────── */}
<div className="flex grow gap-4">
<NvFielddropdown
filterMode="strict"
filterable
options={departmentOptions}
placeholder="Filter by department..."
/>
<NvFielddropdown
filterMode="strict"
filterable
options={statusOptions}
placeholder="Filter by status..."
/>
<NvButton>
Search
<NvIcon name="search" slot="trailing-icon" />
</NvButton>
</div>
{/* RIGHT GROUP: ACTIONS
─────────────────────────────────────────────────────────────────────────
flex → Children arranged horizontally (if multiple buttons).
gap-4 → Consistent 16px spacing between action buttons.
NOTE: No "grow" here! This group stays at its natural width.
Because the left group has "grow", this group gets pushed to the right.
───────────────────────────────────────────────────────────────────────── */}
<div className="flex gap-4">
<NvButton emphasis="medium">
Add User
<NvIcon name="user-plus" slot="trailing-icon" />
</NvButton>
</div>
</div>
{/* DATA TABLE WRAPPER
─────────────────────────────────────────────────────────────────────────────
pb-4 → padding-bottom: 1rem (16px). Adds space between table bottom and
card edge. Prevents content from touching the card boundary.
WHY only pb (padding-bottom)?
- The table component has its own internal horizontal padding
- We only need bottom spacing to match the toolbar's visual weight
- Using p-6 would add unnecessary horizontal padding (double-padding)
───────────────────────────────────────────────────────────────────────────── */}
<div className="pb-4">
<NvDatatable
columns={columns}
rows={data}
pagination={{
mode: 'client',
initialPageSize: 20,
pageSizeOptions: [10, 20, 50, 100]
}}
/>
</div>
</>
);
}
Key Takeaways from this Page Layout:
-
Toolbar Pattern: Use
flexparent with two children—left side withgrow, right side without -
The Power of
gap: Instead of managing margins on individual items,gap-4handles all spacing automatically -
Strategic Padding: Different padding values for different purposes:
p-6on toolbar for consistent inner spacingpb-4on table wrapper to prevent content touching edges- No horizontal padding on table wrapper (component handles it)
-
Visual Separators:
border-b border-lowcreates subtle division between toolbar and content
Advanced Patterns
Creating Reusable Style Components
When you repeat the same utility combinations, extract them into reusable components or classes.
Option 1: React Component
function PageHeader({ title, action }: { title: string; action?: React.ReactNode }) {
return (
<div className="flex items-center justify-between mb-6 pb-4 border-b border-low">
<h1 className="typo-heading-xl-bold text-high">{title}</h1>
{action && <div>{action}</div>}
</div>
);
}
// Usage
<PageHeader
title="Users"
action={<NvButton emphasis="high">Add User</NvButton>}
/>
Option 2: CSS with @apply
Create a CSS file (e.g., custom.css):
.page-section {
@apply bg-level-00 rounded-lg shadow-sm p-6 mb-6;
}
.stat-card {
@apply bg-gradient-to-br from-brand-500 to-brand-700 text-white rounded-lg p-6;
}
.form-section {
@apply border-b border-low pb-6 mb-6 last:border-0 last:pb-0 last:mb-0;
}
Usage:
<div className="page-section">
<h2 className="typo-heading-md-bold mb-4">Overview</h2>
<div className="grid grid-cols-3 gap-4">
<div className="stat-card">
<p className="typo-text-sm-regular opacity-90">Total Revenue</p>
<p className="typo-heading-lg-bold mt-2">€125,000</p>
</div>
</div>
</div>
List Layouts
Display collections of items with consistent spacing and hover effects. Use divide-y for separators between items and negative margins (-mx-4) with padding to extend hover backgrounds beyond container edges:
Key utilities: divide-y, hover:bg-*, negative margins for extended hover areas
function UserList({ users }: { users: User[] }) {
return (
<div className="divide-y divide-low">
{users.map(user => (
<div
key={user.id}
className="py-4 flex items-center justify-between hover:bg-level-10 px-4 -mx-4 rounded"
>
<div className="flex items-center gap-4">
<div className="w-10 h-10 rounded-full bg-brand-100 flex items-center justify-center">
<span className="typo-text-md-medium text-brand-700">
{user.name.charAt(0)}
</span>
</div>
<div>
<p className="typo-text-md-medium text-high">{user.name}</p>
<p className="typo-text-sm-regular text-medium">{user.email}</p>
</div>
</div>
<div className="flex items-center gap-2">
<NvButton size="sm">Edit</NvButton>
<NvButton size="sm" danger>Delete</NvButton>
</div>
</div>
))}
</div>
);
}
Empty States
Empty states guide users when no data is available. Center the content vertically and horizontally, use an icon for visual interest, and provide a clear call-to-action:
Pattern: flex flex-col items-center justify-center for centering, constrained text width for readability
function EmptyState({ message, action }: { message: string; action?: React.ReactNode }) {
return (
<div className="flex flex-col items-center justify-center py-12 text-center">
<div className="w-16 h-16 bg-level-10 rounded-full flex items-center justify-center mb-4">
<NvIcon name="inbox" className="text-low" size="lg" />
</div>
<p className="typo-text-lg-medium text-high mb-2">No items found</p>
<p className="typo-text-sm-regular text-medium mb-6 max-w-sm">
{message}
</p>
{action}
</div>
);
}
// Usage
<EmptyState
message="Get started by creating your first user"
action={<NvButton emphasis="high">Create User</NvButton>}
/>
Best Practices
1. Use Semantic Tokens, Not Primitive Colors
❌ Avoid:
<div className="bg-gray-50 text-gray-900 border-gray-200">
✅ Prefer:
<div className="bg-level-10 text-high border-low">
2. Keep Components Focused
Don't overload components with too many utilities. Extract repeated patterns.
❌ Avoid:
<div className="bg-level-00 rounded-lg shadow-md hover:shadow-lg transition-shadow p-6 border border-low">
✅ Prefer:
// In custom.css
.elevated-card {
@apply bg-level-00 rounded-lg shadow-md hover:shadow-lg
transition-shadow p-6 border border-low;
}
// In component
<div className="elevated-card">
3. Mobile-First Responsive Design
Build for mobile first, then add responsive classes for larger screens.
<div className="
grid grid-cols-1 gap-4 /* mobile */
md:grid-cols-2 md:gap-6 /* tablet */
lg:grid-cols-3 lg:gap-8 /* desktop */
">
4. Consistent Spacing
Use consistent spacing values from the Nova scale:
- Small gaps:
gap-2(8px) - Medium gaps:
gap-4(16px) - Large gaps:
gap-6(24px) - Extra large:
gap-8(32px)
5. Typography Hierarchy
Always use Nova typography classes:
// ❌ Don't use Tailwind font utilities
<h1 className="text-3xl font-bold">
// ✅ Use Nova typography
<h1 className="typo-heading-xl-bold">
Common Pitfalls
1. Conflicting Styles
Be careful when combining Nova component styles with Tailwind:
{/* Nova components already have padding, border-radius, etc. */}
{/* Adding these may cause conflicts: */}
<NvButton className="p-8 rounded-full border-2"> {/* ⚠️ May conflict */}
{/* Better: Use layout utilities only */}
<NvButton className="mt-4 w-full"> {/* ✅ Safe */}
2. Not Using Design Tokens
Always use the Nova token system for consistency:
{/* ❌ Don't hardcode colors */}
<div className="bg-blue-500">
{/* ✅ Use Nova brand or feedback colors */}
<div className="bg-brand-500">
3. Overusing @apply
Don't use @apply for every single element. It's meant for reusable patterns, not one-off styles.
Quick Reference
Essential Layout Classes
// Containers
max-w-7xl mx-auto px-4 py-8
// Flex
flex items-center justify-between gap-4
flex flex-col space-y-4
// Grid
grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6
// Spacing
p-4 px-6 py-8 mt-4 mb-6 gap-4 space-y-6
// Positioning
relative absolute inset-0 top-0 left-0
// Sizing
w-full h-full min-h-screen max-w-md
// Display
hidden lg:block
Breakpoints
sm: 640px // Small devices (landscape phones)
md: 768px // Medium devices (tablets)
lg: 1024px // Large devices (desktops)
xl: 1280px // Extra large devices
2xl: 1536px // 2X large devices
Additional Resources
Get Help
If you need assistance with styling or have questions:
- Check the Nova Storybook for component examples
- Review existing components in your codebase
- Reach out to the Nova Design System team
Remember: Nova handles the components, Tailwind handles the layout. Focus on spacing, positioning, and composition—the components are already beautifully designed for you.