Layout: Grid, Flex & Container Queries
Combine Grid for page structure and Flexbox for alignment inside components. Use container queries to adapt components based on their parent width — not the viewport.
Card Grid Example
Card 1
Card 2
Card 3
Card 4
Card 5
Card 6
.card-grid {{
display: grid;
grid-template-columns: 1fr;
gap: var(--space-4);
container-type: inline-size; /* enable container queries */
}}
@container (min-width: 36rem) {{
.card-grid {{ grid-template-columns: repeat(2, 1fr); }}
}}
@container (min-width: 60rem) {{
.card-grid {{ grid-template-columns: repeat(3, 1fr); }}
}}
Responsive Sidebar
.layout {{ display: grid; grid-template-columns: 1fr; gap: var(--space-6); }}
@media (min-width: 64rem) {{
.layout {{ grid-template-columns: 20rem 1fr; align-items: start; }}
}}