Skip to content

Installation

NightCSS ships as ready-to-use CSS plus an optional Sass subpackage. There is no build step, no config file, and no runtime dependency.

nightcss is the lean default: reset, design tokens, base element styles, layout primitives, and base utility classes only. Breakpoint variants such as p-md-4, d-lg-none, and radius-md-large are not in it. They ship as a separate file so the default stays small.

What you need Import
The lean default (13.0 KB gzip) nightcss
Lean default plus breakpoint classes nightcss, then nightcss/utilities/responsive
One file with everything (pre-2.0 behaviour, 23.1 KB gzip) nightcss/full
Foundation without any utilities nightcss/core
Only the utility families you use nightcss/core, then nightcss/utilities/<family> and its /responsive file

All of these are plain CSS imports. A bundler with CSS support resolves them from dist/; in a plain page you can also link the compiled files directly.

Link the minified bundle directly. @2 pins the major version and receives backward-compatible fixes and additions; pin @2.0.0 for an exact version.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nightcss@2/dist/nightcss.min.css">

That is the lean default: core plus base utilities. To use breakpoint classes, link the responsive file after it:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nightcss@2/dist/nightcss.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nightcss@2/dist/utilities.responsive.min.css">

The order matters: the responsive file must come after the base bundle, because .p-md-4 and .p-4 have the same specificity.

If you want the old all-in-one file, link dist/nightcss.full.min.css instead; do not add the responsive file on top of it, or the breakpoint classes ship twice.

Both bundles are also available as plain (non-minified) files at dist/nightcss.css and dist/nightcss.full.css.

Terminal window
npm install nightcss

Import the lean foundation from a bundler or a plain CSS entry:

@import "nightcss";

Take the full pre-2.0 bundle in one import:

@import "nightcss/full";

Or add breakpoint variants to the lean bundle:

@import "nightcss";
@import "nightcss/utilities/responsive";

The responsive file must come after the base utilities. Breakpoint rules do not raise specificity, so source order is what makes .p-md-4 win over .p-4. A bundler preserves the order of @import statements; if you import NightCSS from JavaScript instead, import the base entry before the responsive one.

With that pair in place, this markup behaves as written — no padding gets wider at 768px:

<div class="p-2 p-md-4 p-lg-6">Grows with the viewport</div>

With only @import "nightcss", the p-md-4 and p-lg-6 classes do nothing at all, because they are not in the file.

Every module is a separate export, so you can ship only what you use:

@import "nightcss/core"; /* reset + tokens + base + layout */
@import "nightcss/reset"; /* modern reset only */
@import "nightcss/tokens"; /* design tokens only */
@import "nightcss/base"; /* base element styles */
@import "nightcss/layout"; /* layout primitives */
@import "nightcss/utilities"; /* base utility classes */
@import "nightcss/utilities/responsive"; /* breakpoint variants */
@import "nightcss/utilities/full"; /* base + breakpoints */

The module exports map to the compiled files in dist/, so importing nightcss/reset pulls dist/reset.css and nothing else.

Each family has its own base file and, when it has breakpoint variants, a responsive companion:

@import "nightcss/core";
@import "nightcss/utilities/spacing";
@import "nightcss/utilities/spacing/responsive";

Families: opacity, motion, radius, shadow, gradient, z, rotation, typography, spacing, sizing, display, flex, position, color, border, overflow, interaction, a11y, grid.

Only these families have breakpoint variants: display, flex, grid, opacity, position, radius, sizing, spacing, typography, z. The others are base-only, and importing a responsive file that does not exist is a resolution error — nothing to load.

Load a family’s responsive file after its base file, for the same source-order reason as the aggregate. Do not combine the aggregate bundle with per-family files — you would ship the same classes twice.

NightCSS needs no Vite plugin. Import it in your entry:

main.js
import 'nightcss';
/* or in style.css */
@import "nightcss";

Import it once in the root layout. Since CSS is a side effect, the import order is enough:

app/layout.tsx
import 'nightcss';

For projects that write SCSS, an optional subpackage ships token maps, accessor functions, and mixins on the modern module system:

@use "nightcss/scss" as nc;
.card {
padding: nc.nc-space(4);
border-radius: nc.nc-radius("md");
}

See Sass Subpackage for the full API.