Using Gap in CSS Grid
The gap (previously called grid-gap) property in CSS Grid is used to create consistent spacing between grid rows and columns without adding extra margins to grid items.
Defines the space between rows and columns in a grid layout.
Can be specified as a single value (applies to both rows and columns) or two values (row-gap and column-gap).
Improves readability and layout consistency by avoiding manual spacing on individual grid items.
Works in both CSS Grid and Flexbox (as gap in Flexbox).
Example: gap: 20px; adds 20px spacing between all rows and columns.
You're building a product grid with 3 columns, but the items are squished together — how would you use gap to fix it?
If you set gap: 20px on a grid but the layout still looks cramped, what’s the first thing you’d check?
You set gap: 1rem on a grid container, but the spacing only appears vertically — why might that be?
A designer says the spacing between cards in our dashboard grid looks inconsistent on mobile — you’ve used gap, but it’s not working as expected. How do you debug this?
Your team’s grid layout breaks when content overflows — you suspect gap is part of the issue. What’s your investigation plan?
We’re migrating from margin-based spacing to CSS grid with gap, but now our responsive breakpoints behave differently. What’s likely causing this?
You’re designing a dynamic grid component that adapts to user-defined column counts — how do you ensure gap remains visually consistent across all screen sizes and content loads?
Our grid-based component is used in 12 different products with varying theme tokens — how do you architect gap values to be maintainable and theme-aware without hardcoding?
A performance audit shows layout thrashing in our grid-heavy dashboard. Could gap be contributing? How would you verify and optimize?
We’re standardizing our design system across 50+ teams using CSS grid — how do you decide whether to enforce gap as a token, a utility, or a component prop, and what tradeoffs do you weigh?
Legacy code uses margin-based spacing in grids; migrating to gap requires breaking changes. How do you plan and communicate this migration to avoid regressions across products?
Our grid system is used in high-traffic pages with dynamic content. How would you evaluate whether gap impacts layout stability, repaint performance, or accessibility at scale?