CSS Variables (Custom Properties)
css-variables
Code Snippets
Dark Mode with CSS Variables
Implementing dark mode without a heavy theming library comes down to a stable token contract and a media query. This snippet covers the system-preference dark mode using `prefers-color-scheme`, a class-based override that lets users opt in or out, and a per-component theme that nests tokens for a single section.
CSS Preprocessor Features Cheat Sheet
If you have used SCSS or Less, you know variables, nesting, and mixins as preprocessor features. Native CSS now offers all three: custom properties (`--var`), the CSS Nesting Module, and `@layer`. This snippet shows the SCSS form alongside the native form for each so you can see when you actually need a preprocessor and when plain CSS is enough. Audience: practitioners moving from SCSS to native CSS and wondering what they get to drop.
Community
The 12-Column Grid I Keep, With Named Areas and Container Queries
I rewrote our marketing site grid three times before settling on this: a 12-column CSS Grid with named areas for the hero shape, container queries for the breakpoints, and custom properties for the gutter so designers can change one value.
The Theme-Switcher Context I Drop Into Every App
The drop-in `<ThemeProvider>` I keep in my dotfiles. CSS variables, `prefers-color-scheme` integration, and `localStorage` persistence in about 60 lines.
