skip to content

Stylesheet Tooling

Rival ways to write CSS beyond the language: compile it from Sass, transform it with PostCSS, scope it per file, author it in JavaScript or compose utilities. Interviewers ask which fits a team.

on this pageshow

explore

questions

page 2 of 2

After a catalogue app moves to CSS Modules, a BookCard rule `img { border-radius: 8px }` rounds every image site-wide and `.card a` restyles links in nested components — what does CSS Modules scoping not protect?

level: seniorimportance: should knowfreq 9%

basics

~20 s

CSS Modules rename class, ID and keyframes names; they do not limit where a rule reaches. Element selectors stay global, descendant selectors match nested components, order between modules follows load order, and inherited values still flow down.

open as a page

In Dart Sass, why does `@use "campus-ui/tokens" with ($radius: 2px)` fail when another file loaded that module first, and how do you fix it?

level: seniorimportance: should knowfreq 8%

basics

~20 s

A module is loaded once per compilation and keeps the configuration of its first load, so @use ... with() works only on that first load. Configure the library at the top of the entry point, before anything else loads it.

open as a page

In Sass, what CSS do a %placeholder with @extend and a mixin each emit for shared styles, and why can't @extend reach across @media?

level: seniorimportance: should knowfreq 10%

basics

~20 s

A mixin copies its declarations into every rule that includes it. @extend adds the extending selector to the existing rules, so a %placeholder yields one grouped rule. Inside @media, @extend can only reach selectors in that same media context.

open as a page

In Tailwind CSS v4, `@theme { --font-display: var(--font-lora), serif; }` makes `font-display` headings render in the default font, though `<body>` sets `--font-lora`; why, and what fixes it?

level: seniorimportance: should knowfreq 9%

basics

~20 s

Without the inline option, font-display compiles to var(--font-display), and that variable is computed on :root, where --font-lora does not exist yet. @theme inline puts var(--font-lora) into the utility itself, so it resolves on the heading.

open as a page

In Tailwind CSS v4, editors add utility classes to marketing content fetched from a CMS at run time; how do you guarantee those utilities are generated?

level: seniorimportance: should knowfreq 9%

basics

~20 s

Safelist them in the stylesheet with @source inline(), added in Tailwind CSS 4.1, which forces the listed utilities to be generated and brace-expands patterns such as {hover:,}bg-rose-{100,600}. v3's safelist option is not supported in v4.

open as a page

After upgrading a project to Tailwind CSS v4, `md:btn` in markup generates nothing and `@apply btn` fails, though `.btn` still sits in `@layer components` — why, and what are your options?

level: seniorimportance: should knowfreq 6%

basics

~20 s

Tailwind CSS v3 turned classes inside @layer components into utilities, so variants and @apply worked on them. v4 emits native cascade layers and leaves that CSS as ordinary rules, so either register the class with @utility or move its states inside the rule.

open as a page

In Tailwind CSS v4, in which order are stacked variants such as `*:first:font-semibold` applied, and what CSS does a stacked class compile to?

level: seniorimportance: should knowfreq 8%

basics

~20 s

Tailwind CSS v4 applies stacked variants left to right, like nested CSS: the leftmost variant is the outermost condition. v3 read them right to left, so order-sensitive classes such as first:*: had to be reversed to *:first: in v4.

open as a page

In Tailwind CSS v4, what do the `--spacing()` and `--alpha()` functions compile to in your own CSS, and why use them over hard-coded values?

level: middleimportance: nice to knowfreq 4%

basics

~20 s

In Tailwind CSS v4, --spacing(4) compiles to calc(var(--spacing) * 4) and --alpha(var(--color-x) / 50%) to color-mix(in oklab, var(--color-x) 50%, transparent). Both keep hand-written CSS on the theme's scale and palette, so changing a theme variable updates them too.

open as a page

In Tailwind CSS v4, how do you apply a variant such as `dark` or `hover` inside your own CSS rule, and what does it compile to?

level: middleimportance: nice to knowfreq 7%

basics

~20 s

In Tailwind CSS v4, @variant dark { … } inside a rule wraps that block in the variant's condition: by default dark becomes a prefers-color-scheme media query and hover becomes &:hover inside @media (hover: hover). Stacked and comma-separated lists arrived in 4.3.0.

open as a page

In Tailwind CSS v4, why does a card's `hover:` lift never show when tapped on a phone, and what should touch and keyboard users get?

level: middleimportance: nice to knowfreq 10%

basics

~20 s

Tailwind CSS v4 wraps every hover: rule in @media (hover: hover), so it applies only when the primary input device can hover; a phone's touchscreen cannot. Give keyboard users focus-visible: styles and touch users active: feedback.

open as a page

Why do runtime CSS-in-JS styles run into a style-src policy without 'unsafe-inline', and what changes when the styles are extracted at build time?

level: seniorimportance: nice to knowfreq 4%

basics

~20 s

A runtime library writes its rules into style elements, which style-src treats as inline style blocks; without 'unsafe-inline' they need a matching nonce or hash. Extraction emits linked .css files from your origin, which 'self' already allows, so nothing inline remains.

open as a page

When would you replace a PostCSS pipeline of postcss-preset-env and cssnano with Lightning CSS, and what does the switch give up?

level: seniorimportance: nice to knowfreq 4%

basics

~20 s

Lightning CSS is a single Rust-based transformer that lowers modern syntax for browser targets, prefixes and minifies in one fast tool. Switch when the pipeline is only standard lowering and minifying; stay on PostCSS while you depend on PostCSS plugins.

open as a page

When writing a PostCSS 8 plugin that rewrites a legacy --gutter-units declaration, which listeners do you use, and how do you avoid an endless re-visit loop?

level: seniorimportance: nice to knowfreq 5%

basics

~20 s

Export a creator, flagged postcss = true, returning postcssPlugin and listeners. Use a Declaration listener keyed to --gutter-units, prepare(result) for per-file state, and make each change stop matching, since PostCSS 8 re-visits every changed node.

open as a page

A shared Sass library built on @import and global functions floods consumer builds with Dart Sass deprecation warnings; how do you migrate it to the module system safely?

level: seniorimportance: nice to knowfreq 6%

basics

~20 s

Run sass-migrator module --migrate-deps on the entry point to turn @import into @use/@forward and global functions into sass: module calls, forward the public API from the index, keep an import-only file for old consumers, and gate CI on deprecations.

open as a page

When upgrading a Tailwind CSS v3 project with a `tailwind.config.js` to v4, what happens to the config's theme, and when do you keep the file through `@config`?

level: seniorimportance: nice to knowfreq 6%

basics

~20 s

Tailwind CSS v4 no longer detects tailwind.config.js. The upgrade tool converts a simple config to @theme variables; a config with presets, unknown keys or plugins it cannot read is kept and loaded with @config, minus options like safelist and corePlugins.

open as a page

In a Tailwind CSS v4 monorepo built from the repository root, the dashboard's stylesheet carries other apps' utilities and misses a git-ignored CMS export folder; how do you control what it scans?

level: seniorimportance: nice to knowfreq 6%

basics

~20 s

Tailwind CSS v4 scans from the build's working directory, so a root build reads every app. Move the base with source("../src") or disable detection with source(none), then add the CMS folder with @source and drop dead folders with @source not.

open as a page

showing 31–46 of 46