<dialog>Dialog pattern
Focus, Escape and the backdrop come from the browser.
No config, no JavaScript, no build step.
The left side is the browser default. The right side is the same HTML after one import and a few lines of your own CSS.
Drag the divider, or focus it and use the arrow keys, to compare the two renderings.
Five layers in one file. Unlayered CSS — yours — always wins.
:root {
--nc-accent: light-dark(oklch(48% 0.16 225), oklch(75% 0.12 225));
--nc-radius-md: 4px;
--nc-space-4: 16px;
--nc-text: light-dark(oklch(23% 0 0), oklch(76.4% 0 0));
--nc-text-muted: light-dark(oklch(42% 0 0), oklch(60.6% 0 0));
}Import one module and the rest never reaches the browser.
| Module | Raw | gzip | brotli | gzip bar |
|---|---|---|---|---|
reset.css | 0.5 | 0.3 | 0.2 | |
tokens.css | 5.3 | 1.7 | 1.4 | |
base.css | 2.4 | 0.8 | 0.6 | |
layout.css | 3.5 | 0.9 | 0.6 | |
utilities.css | 73.3 | 9.7 | 5.9 | |
nightcss.css | 84.9 | 13.0 | 8.3 |
src/
├── reset.css
├── tokens/ 8 files
├── base/ 3 files
├── layout/ 8 files
├── utilities/ 12 files + generated
├── core.css
├── full.css
└── index.css<dialog>Focus, Escape and the backdrop come from the browser.
<details>Box-sizing, margins, media and form normalization. It is 0.3 KB gzip.
A summary and a disclosure. No JavaScript, no aria-expanded to maintain.
:has()The card reacts to its own checkbox. No class toggling in script.
popoverA popover opens above the page with one attribute. Light dismiss is built in.
All four are in the browser. NightCSS only sets the baseline.
Open the native-pattern guidesNightCSS normalizes like a reset, ships tokens and layout like a framework, and leaves components to you.
| Foundation | Build | JavaScript | Tokens | Layers | Container queries | gzip |
|---|---|---|---|---|---|---|
| Tailwind CSS | config or CDN | — | theme config | yes | yes | ~3–15 KB, used classes |
| Bootstrap | — | required | CSS variables | — | — | ~46 KB, CSS + JS |
| Pico CSS | — | optional | CSS variables | yes | — | ~9 KB |
| Open Props | — | — | --* | — | — | ~14 KB |
| NightCSS | — | — | --nc-* | yes | yes | 13.0 KB |
Sizes are approximate gzip for the latest major versions; NightCSS is measured for its lean default (the full bundle is 23.1 KB).
Read the installation guideThe base layer styles the elements the browser already ships: headings, links, code, forms and media.