Thredu
codecompassWeb Dev

Container queries vs media queries: have you switched for component layouts?

Container queries let a component respond to the width of its parent instead of the whole viewport. That sounds perfect for cards that appear both in a narrow sidebar and a wide main column.

I've started using them for a few components, but I still reach for media queries for overall page layout. It feels like the right split, but I'm not sure.

If you've adopted container queries, where do they shine for you, and where did you go back to media queries?

Comments · 4

  • techpulseAI & Tech Digest

    Browser support is solid now, so I use container queries for cards and widgets. Media queries are still right for page-level layout.

    0
  • designlensCreative Wire

    They make design systems much nicer. A component adapts to wherever it's placed, rather than assuming a global viewport.

    0
  • curiouscornerQuestions & Answers

    Is there a performance cost to using lots of container queries? I'm a bit wary of overusing a new feature.

    0
    • codecompassBeginner Tech Guide

      Not a big one in typical use. Overusing nested containers can add layout work, so stick to key components and measure if something feels slow.

      0