Nue treats CSS as a first-class citizen rather than a side effect of component rendering. Instead of scoping styles inside JavaScript components or generating utility class strings at build time, Nue relies on the browser’s built-in cascade — the mechanism CSS was designed around. Global stylesheets live next to your content, design tokens flow through custom properties, and every layer from reset to page-specific overrides has a predictable place.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nuejs/nue/llms.txt
Use this file to discover all available pages before exploring further.
Why CSS-first instead of CSS-in-JS
Modern frameworks commonly co-locate styles with components using CSS Modules, styled-components, or utility class libraries like Tailwind. Nue takes the opposite position: styles belong in.css files that are separate from markup and logic.
CSS-in-JS approach
Styles are coupled to component trees. Changing a global design token requires hunting through dozens of component files. The cascade is treated as a bug rather than a feature.
Nue's CSS-first approach
Styles live in dedicated files that any page or component can share. The cascade resolves specificity predictably, and updating a design token in one place propagates everywhere.
The separation of concerns principle that guides Nue’s overall architecture — HTML for structure, JS for behavior, CSS for design — applies just as strictly to styling as it does to routing or data loading.
Global stylesheets and the @shared directory
Nue looks for CSS in a directory called @shared at the root of your project. Files placed here are automatically available to every page and application in your site. You do not need to import them explicitly.
How the cascade works in Nue
Styles resolve in three layers of increasing specificity. Each layer narrows scope from site-wide to application-specific to page-specific.Shared styles
CSS in
@shared/ applies to the entire site. This is where your design tokens, base reset, typography scale, and reusable component styles live.App styles
Each application directory (for example
blog/ or store/) can include its own .css files. These apply to every page within that application and can override shared styles.!important rule or a scoping wrapper — you simply place your override at the right layer.
Design system layers
A complete Nue design system follows five layers, each with a distinct responsibility.Reset
Reset
Strips browser default margins, paddings, and box model inconsistencies. Nue recommends a minimal reset that preserves meaningful defaults like
rem-based font sizes.Design tokens
Design tokens
CSS custom properties that encode your brand decisions: color palette, typography scale, spacing rhythm, border radius, and shadow depth. Tokens are the single source of truth for every visual decision.
Layout
Layout
Grid and flex patterns for page-level structure: the main content area, sidebars, header, footer, and spacing between major sections.
Components
Components
Reusable UI patterns like buttons, cards, navigation, and form elements. Component styles target semantic HTML elements and BEM-style class names, never deeply nested selectors.
Utilities
Utilities
Single-purpose helper classes for spacing, text alignment, display, and visibility. Keep this layer small — utility classes that duplicate component styles create maintenance debt.
Semantic HTML and external CSS
Nue’s component model encourages writing semantic HTML. An article, a navigation list, and a figure are expressed as<article>, <nav>, and <figure> — not as <div class="article-wrapper">. This matters for styling because semantic elements carry implicit meaning that CSS selectors can target directly without extra classes.
File naming conventions
Consistent naming makes it easy to understand which CSS applies to which scope at a glance.| File | Scope | Example |
|---|---|---|
@shared/design/*.css | Entire site | tokens.css, layout.css |
<app-dir>/<app-name>.css | One application | blog/blog.css |
<page-name>.css | One page | about.css, contact.css |
Including and excluding CSS files
You can control exactly which CSS files are loaded usingsite.yaml. This is useful when a stylesheet is experimental, environment-specific, or should only apply under certain build conditions.
include array adds files to every page beyond those auto-discovered by Nue’s dependency resolver. The exclude array removes a file from all pages, useful for disabling a global stylesheet in specific scenarios.
Responsive design without a framework
Nue relies on standard CSS media queries and the cascade. No responsive utility classes, no breakpoint configuration in JavaScript — just CSS.Dark mode
Dark mode is a token swap, not a separate stylesheet. Override your color tokens under aprefers-color-scheme media query or a [data-theme="dark"] attribute: