Sass interviews cover variables, nesting, mixins, and how preprocessors compile to CSS teams still maintain at scale.
15 Sass Interview Questions with Answers
Use the short version first, then offer trade-offs if the interviewer wants depth.
1. What is Sass and how does it relate to CSS?
Sass is a CSS preprocessor that adds variables, nesting, mixins, functions, and modules, then compiles to standard CSS browsers understand. SCSS uses CSS-like braces; indented Sass omits them. Teams use it to organize large stylesheets and share design tokens before native CSS caught up.
2. Difference between @import and @use?
@import duplicated globals and made load order fragile—deprecated in favor of @use, which loads a module once with namespaced members (use "colors" as c). @forward re-exports a module API for barrel files. @use improves encapsulation and compile performance.
3. What are Sass variables and how do they differ from CSS custom properties?
Sass variables ($primary) are compile-time—they disappear in output CSS. CSS custom properties (--primary) exist at runtime and cascade, enabling theming per component or media query. Modern codebases often use Sass for build-time tokens and CSS variables for runtime theme switching.
4. Explain mixins and when to prefer them over extends.
Mixins @mixin flex-center { display: flex; align-items: center; } accept arguments and output rules wherever @include is called—flexible but can bloat CSS if overused. @extend reuses selector groups, which can create unexpected long compound selectors; mixins are safer for parameterized patterns.
5. What problems does nesting cause?
Deep nesting mirrors HTML structure and inflates specificity, making overrides harder (.nav ul li a span). Best practice: nest only for pseudo-states and direct child context, rarely more than three levels. Flat BEM-style classes often beat deep Sass nesting in maintainability.
6. How do partials organize a Sass project?
Partials start with underscore (_buttons.scss) and are imported via @use without generating standalone CSS files. Structure by abstracts (variables, mixins), components, layout, and pages. Entry file (main.scss) @use modules in dependency order.
7. What is the !default flag?
Assigning $brand: #333 !default sets the value only if not already defined—useful in theme partials consumers override before @use. It supports library-style Sass packages where apps customize tokens without editing vendor files.
8. Describe @each, @for, and @while loops in Sass.
@each iterates lists or maps—common for generating utility classes from a spacing map. @for counts between bounds for grid columns. @while loops until a condition fails—use sparingly. Loops generate repetitive CSS at compile time; guard output size in design systems.
9. How does Sass compile in modern frontend toolchains?
Dart Sass is the canonical implementation, run via sass CLI, Vite/Webpack loaders, or framework integrations. It outputs CSS plus optional source maps for debugging. node-sass (LibSass) is deprecated—always specify dart-sass in interviews.
10. What are placeholder selectors (%) and @extend?
%btn-base { padding: 0.5rem; } holds rules extended by other selectors without generating a standalone class until extended. @extend .btn or @extend %btn-base groups selectors in output. Over-extending creates unmaintainable selector lists—prefer mixins for shared parameterized blocks.
11. How do you share design tokens with Sass maps?
Define $colors: (primary: #0066cc, danger: #cc0000) and access via map.get($colors, primary) in modern module syntax. Pass maps to mixins for consistent spacing scales. Document token names because compile-time maps do not auto-sync to Figma without discipline.
12. Sass vs PostCSS—when would you choose each?
Sass adds language features at authoring time. PostCSS transforms CSS with plugins (autoprefixer, preset-env) often after Sass compilation. Many pipelines run Sass first, then PostCSS. Choose Sass for variables/mixins architecture; PostCSS for future CSS polyfills and linting.
13. How do you avoid specificity wars in Sass codebases?
Prefer single-class BEM components, limit nesting depth, avoid tag selectors in nested rules, and use mixins for repeated declarations instead of chaining extends. Regular audits with stylelint and specificity calculators catch runaway selectors early.
14. What is the @mixin content block pattern?
@mixin respond($breakpoint) { @media (min-width: $breakpoint) { @content; } } lets callers pass a block: @include respond(768px) { .grid { columns: 2; } }. It is the Sass equivalent of higher-order mixins for media queries and themes.
15. When should a team migrate away from Sass toward native CSS?
Native CSS now has variables, nesting (in modern browsers), @layer, and color functions. Evaluate if Sass only wraps features CSS provides—migration reduces build steps. Keep Sass when heavy mixins, map-driven generation, or legacy design systems depend on it until a phased CSS-first plan exists.
Pro Tip
Mention limiting nesting depth and BEM naming—senior interviews connect Sass features to long-term CSS maintainability.