12 March 2025

CSS Container Queries

Finally getting around to using container queries. The @container rule is a game changer for component-based design. No more media query frustration!

Container queries changed everything for component design.

Before: Components would break at arbitrary viewport breakpoints

@media (min-width: 768px) {
  .card { flex-direction: row; }
}

After: Components adapt to their container

@container (min-width: 400px) {
  .card { flex-direction: row; }
}

Now my components work anywhere—I can stick a card in a sidebar, a main column, or a modal, and it adapts automatically.

Read the MDN guide on container queries to get started.