Contact us

Blog  /  Engineering

Responsive design moved into the component

Responsive web design is no longer a viewport problem. Container queries let a component respond to the width of the box it sits in, which is the thing media queries could never see, and that changes how design systems should be built.

Responsive design moved into the component

Key takeaways

  • Container queries are production ready: size queries sit at 94.05 percent of global browser usage, which is past the point where support is the deciding factor.
  • Media queries are not obsolete, they are reassigned: they own page-level decisions such as navigation collapse and page grid columns, while container queries own everything inside a component.
  • Usage lags capability badly, with 41 percent of surveyed developers having tried size container queries and only 7 percent style queries, so most design systems still carry breakpoint variant classes they no longer need.
  • Fluid typography with clamp() has to be tuned per type role rather than applied as one global curve, because a curve that flatters headlines usually ruins body copy at the same width.
  • Component breakpoints change the design system contract: the unit of design becomes a component’s own width range, and Figma variants should be named for width, not for device class.

What changed in responsive web design since media queries?

Responsive web design used to mean one thing: ask the viewport how wide it is, then lay the page out to suit. That assumption is now the limitation. Container queries let an element read the width of the box it has been placed in rather than the width of the browser window, so a single component can be correct in a sidebar, inside a three-column grid and at full bleed without a variant class for each.

The capability is not experimental any more. Size container queries sit at 94.05 percent of global browser usage.1 Support is no longer the deciding factor. Adoption is: 41 percent of State of CSS survey respondents had used size container queries at least once, and only 7 percent had used style queries, against awareness that rose from 81 percent to 86 percent.2 Most production codebases are still solving a component problem with a page-level tool.

94.05%Globalbrowser support86%Developerawareness41%Have usedsize queries7%Have usedstyle queries
Container queries: one browser support figure and three developer survey answersSource: caniuse.com 2026 and State of CSS Survey 2025

Two other shifts landed alongside. Fluid typography using clamp() replaced the stepped type scale, so text sizes move continuously instead of jumping at arbitrary widths. And intrinsic layout, mainly grid with auto-fit and minmax, absorbed a large share of the cases that used to need a breakpoint at all.

What are container queries, and how do they differ from media queries?

A container query applies styles based on the size of an element’s nearest registered ancestor container. A media query asks about the browser window. That is the entire difference, and it decides which one you should reach for.

Two declarations are involved. A parent opts in, and the child queries it.

.card-slot { container: card / inline-size; }

.card { display: grid; gap: 1rem; }

@container card (min-width: 28rem) {
  .card { grid-template-columns: 9rem 1fr; align-items: start; }
}

Note inline-size rather than size. Querying inline size measures width only and leaves height to content, which sidesteps the circular layout problem that makes full size containment awkward in normal document flow. Naming the container is optional and worth the discipline anyway, because an unnamed query resolves to the nearest container ancestor, and that ancestor changes the moment someone nests your component inside another one.

Container query units come with the feature. 1cqi is one percent of the container’s inline size, so padding, gaps and type can scale against the component’s own box rather than the page: padding: clamp(1rem, 4cqi, 2rem).

The failure mode this fixes is specific. A media query cannot distinguish a card that is narrow because the phone is narrow from a card that is narrow because it was dropped into a sidebar on a wide desktop. Both need the stacked layout. Only one of them gets it.

A component that has to be told where it is has not been designed. It has been configured.

One gotcha to plan for: declaring container-type applies layout containment, which makes that element a containing block for absolutely and fixed positioned descendants and creates a new stacking context. Sticky headers and dropdown menus that escape their parent will behave differently once you register the container around them. And an element cannot query itself, only an ancestor, so the container has to be the slot rather than the component.

Do container queries replace media queries?

No, and treating them as competitors misapplies both. The split that holds up in practice is by the decision being made, not by preference.

DecisionRight toolWhy
Navigation collapses to a menu buttonMedia queryPage-level state, not a function of any one component’s width
Page grid drops from three columns to oneMedia queryThe page grid is the container, so something above it has to set the width
Card switches from stacked to horizontalContainer queryDepends only on the slot the card was placed in
Data table degrades to a stacked listContainer queryThe same table appears in a full-width dashboard and in a narrow drawer
Type and spacing inside a componentclamp() with container unitsContinuous, so no breakpoint is needed at all
Reduced motion, colour scheme, printMedia queryNot size conditions; these are user and device preferences

A rule that survives contact with a real codebase: if the answer to “how wide is this?” would change when someone moves the component to another part of the page, it is a container query. If the answer only changes when the user resizes the window, it is a media query.

How should fluid typography be set with clamp()?

clamp() takes a minimum, a preferred value and a maximum. The preferred value should mix a rem base with a viewport or container unit, so the type stays continuous without breaking browser zoom.

h2 { font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.5rem); }
p  { font-size: clamp(1rem, 0.98rem + 0.15vw, 1.125rem); }

Note the two very different curves. This is where most type scales go wrong. A single global clamp curve applied across the whole scale makes headlines feel right and body copy feel wrong at the same viewport, because headings want a wide range and body text wants almost none. Body copy should shift by a couple of pixels across the entire width range. A display heading can shift by twenty. Scope the curve per role, not per stylesheet.

Two constraints belong in the system rather than in a developer’s head. Never use a bare viewport unit as the preferred term, because a font size expressed purely in vw ignores browser zoom, and that is an accessibility failure rather than a style choice. And cap the measure as well as the size: setting max-inline-size in ch units on text containers does more for readability than any amount of clamp tuning.

Is mobile first design still the right default?

Yes, for two independent reasons, and the second one holds even if the first stops being true.

The traffic reason is straightforward. Mobile devices account for 58.5 percent of global website traffic,3 and a separate roundup puts mobile screens at close to 60 percent of page views worldwide.4 The narrow case is the majority case.

The authoring reason matters more and is unchanged by container queries. Mobile first means the base stylesheet describes the smallest, simplest layout, and every query adds to it. That keeps the base lean and lets container queries and media queries layer complexity on progressively. A desktop-first base does the reverse: it ships a heavy stylesheet that every narrow context then has to override, which means more CSS, more specificity fights and more opportunities for a component to inherit a layout it never asked for.

Mobile first also gives container queries a free fallback. Browsers without support ignore an @container block entirely rather than erroring, so an unsupported browser lands on the base narrow layout, which is a usable page rather than a broken one. Where a wider layout genuinely matters, wrap the alternative in @supports not (container-type: inline-size).

How do component breakpoints change a design system?

They change the unit of design. A page breakpoint system asks what a screen looks like at the tablet breakpoint. A component breakpoint system asks what a card does across its own width range, and above where it stops fitting. The second question is the one a design system can actually answer, because a component never knows what page it is on.

Three consequences for teams running a system across design and code:

  • Name Figma variants for width ranges of the component, not for device classes. A variant called “Card / narrow” survives a redesign. “Card / mobile” does not, because it encodes an assumption that the component cannot verify.
  • Express spacing and type tokens inside a component in container units where the value should track the component. That removes a whole category of variant: one definition covers three slots.
  • Document a supported width range per component. Without it, a component is only ever tested at the widths it happened to be used at, and every new placement is a fresh bet.

The payback shows up in delivery rather than in aesthetics. Teams doing serious web development against a shared component library lose a meaningful share of review time to layout regressions caused by components being reused in contexts they were never sized for. Component-level breakpoints remove that category of defect rather than catching it later. The same logic holds when a system spans web and a native mobile app, where the component, not the screen, is the only stable unit across both.

What does responsive web design do for rankings and Core Web Vitals?

Google does not rank a page for being responsive. It indexes the mobile version of the page, and responsive design is the configuration Google recommends under mobile-first indexing, because one URL and one HTML payload serve every device.8 The benefit is the absence of failure: no content missing from the mobile HTML, no blocked resources, no structured data that exists on one device version and not the other.

Everything else runs through user behaviour and Core Web Vitals rather than through a responsiveness signal.

58.5%Mobile shareof web traffic11%Reportedconversion lift60%Bounce rate,non-optimised mobile
Three widely quoted responsive design numbers, each measuring something differentSource: Statista 2025; Celerart 2025; WPDean 2025

Read those bars as three separate measurements, because that is what they are. Industry aggregations put responsive sites at roughly 11 percent higher conversion rates than non-responsive ones,6 and non-optimised mobile sites at an average 60 percent bounce rate.7 Both come from vendor aggregation rather than controlled study, so treat them as direction rather than a forecast for your own site. The traffic share is the number to plan against.

The Core Web Vitals link is mechanical. Cumulative Layout Shift is mostly images and embeds without reserved dimensions, which responsive image handling fixes directly. Largest Contentful Paint on mobile is usually a hero image sized for desktop and delivered to a phone. Neither is a CSS layout problem, which is why a site can be fully responsive and still fail the vitals assessment.

What belongs on a responsive web design checklist?

  1. Write the base stylesheet as the narrowest layout, with no width queries in it at all. Everything after that is an addition, never an override.
  2. Register containers on layout slots, not on components. The slot declares container-type; the component queries it by name.
  3. Use inline size containment unless you have a real reason to constrain height, and expect a containing block and a stacking context wherever you register one.
  4. Reserve media queries for page chrome, the page grid, and non-size conditions such as reduced motion, colour scheme and print.
  5. Give every clamp() curve a role. Body copy barely moves, display type moves a lot, and no curve uses a bare viewport unit as its preferred value.
  6. Try grid auto-fit with minmax before writing any query. A large share of column-count breakpoints are not needed once the grid can size itself.
  7. Set width and height attributes on every image so nothing shifts while it loads, and identify the mobile Largest Contentful Paint element specifically rather than assuming it matches desktop.
  8. Test each component at its declared minimum and maximum width in isolation, not only inside the page it was built for.
  9. Confirm the mobile HTML contains everything the desktop HTML contains, structured data included.

None of this is a rewrite of how responsive web design works. It is a reordering. Decide at the component level by default, and escalate to the page level only when the page is genuinely what changed. Teams that make the switch during the design phase of a build spend far less time later unpicking variant classes that exist only because a component could not see its own width. For teams weighing that change across an existing product, our engineering practice treats it as a design system decision first and a CSS one second.

Frequently asked questions

What is responsive web design, and how is it different from adaptive design?

Responsive web design uses one fluid layout that reflows continuously at every width, from a single URL and a single HTML payload. Adaptive design serves one of several fixed layouts chosen at set breakpoints, often decided on the server by device detection. Responsive is the configuration Google recommends under mobile-first indexing because there is only one version of the page to index. Adaptive can be tuned harder for known devices, at the cost of maintaining several layouts and keeping their content in sync.

Do container queries work in all browsers, and what happens if they do not?

Size container queries are supported across 94.05 percent of global browser usage as measured by caniuse in 2026. Browsers without support ignore the whole @container block rather than throwing an error, so if the base stylesheet is written mobile first, an unsupported browser simply lands on the narrow layout. That is a usable page for most content. Where a wider layout genuinely matters, wrap an alternative in @supports not (container-type: inline-size).

Can container queries replace CSS Grid or Flexbox?

No. Grid and flexbox decide how items are arranged; container queries decide when those arrangement rules change. What container queries do replace is a class of breakpoint hack, such as adding a viewport media query purely to change a grid's column count inside one component. Many of those cases need no query at all once you use grid auto-fit with minmax and let the grid size itself.

How do I implement fluid typography with clamp()?

Set font-size to clamp(minimum, preferred, maximum), where the preferred value adds a viewport or container unit to a rem base, for example clamp(1.5rem, 1.1rem + 1.8vw, 2.5rem). Keep the rem term in the preferred value, because a font size expressed purely in viewport units ignores browser zoom and breaks accessibility. Give each type role its own curve: body copy should move only slightly across the full width range, while a display heading can move a lot.

Is mobile first design still the right default?

Yes, on both traffic and authoring grounds. Statista put mobile devices at 58.5 percent of global website traffic in 2025, so the narrow case is the majority case. Independently of traffic, writing the base stylesheet for the smallest layout keeps it lean and lets container and media queries add complexity progressively, rather than forcing every narrow context to override a heavy desktop-first base.

Does responsive design affect Google rankings and Core Web Vitals?

Not as a direct ranking factor. Google indexes the mobile version of a page under mobile-first indexing and names responsive design as its recommended configuration, because the same HTML and structured data reach every device. The effect on rankings is indirect: a responsive page avoids content that is missing on mobile, and it removes one common source of layout shift. Core Web Vitals still have to be fixed separately, since layout shift and slow largest contentful paint on mobile usually come from unsized images rather than from CSS layout.

Sources

  1. caniuse.com: CSS Container Queries (Size) browser support table, 2026. caniuse.com
  2. State of CSS Survey: container query awareness and usage, reported by LogRocket, 2025. blog.logrocket.com
  3. Statista: Share of website traffic coming from mobile devices, 2025. statista.com
  4. Figma: Web design statistics resource library, 2026. figma.com
  5. Delhi Digital Developer: responsive websites and Google ranking roundup, citing Google research on mobile abandonment, 2026. delhidigitaldeveloper.com
  6. Celerart: Responsive web design statistics, 2025. celerart.com
  7. WPDean: Responsive design statistics, 2025. wpdean.com
  8. Google Search Central: Mobile-first indexing documentation, 2026. developers.google.com
From the practiceEngineeringWe build software for years of use.See the practice

Written by the group's editorial team with the practice leads who run these builds. Reviewed before publish. Spotted an error? Tell us and we will fix it.

A person reads everything that arrives.

Tell us what you are trying to build. You will hear back quickly.

Contact us