Container Queries Generator
The first genuinely interactive CSS @container playground. Drag a resizable preview container and watch a real component re-flow as your breakpoints fire — then export the @container CSS, SCSS, or Tailwind (v4 built-in & v3 plugin) utilities. Includes presets and a cq* units reference.
About this ToolHow it works, benefits & use casesTap to collapse
Most container-query references show you the syntax and leave you guessing how it will actually behave — this is a live playground where you size the container yourself. Drag the resizable preview box (or use the width slider) from 200px to 800px and watch a real card component re-flow as each of your breakpoints fires, with the currently active breakpoint highlighted in real time. You define the containment context by setting a container-name and choosing a container-type (inline-size, size, or normal), pick the child selector your rules target, then add as many @container breakpoints as you need. Each breakpoint takes an optional min-width and max-width plus a small CSS editor for the declarations applied at that range, and you can reorder or delete them freely. Start from presets like a card that goes from stacked to side-by-side, a sidebar-or-stack layout, fluid responsive typography, or a 1-to-3-column product grid. When it looks right, export plain CSS, SCSS with nested @container blocks, Tailwind v4 (where @container is built in), or Tailwind v3 using the official @tailwindcss/container-queries plugin. A reference card explains every cqw, cqh, cqi, cqb, cqmin, and cqmax unit.
How to Use
- 1Set the container name and choose a container-type — inline-size is the common width-aware default.
- 2Set the child selector (e.g. .card) that the breakpoint rules should restyle inside the container.
- 3Add breakpoints, giving each a min-width and/or max-width and the CSS declarations to apply in that range.
- 4Drag the resizable preview box or move the width slider to watch the active breakpoint change and the card re-flow.
- 5Load a preset (card, sidebar/stack, responsive typography, product grid) as a starting point and tweak it.
- 6Pick CSS, SCSS, Tailwind v4, or Tailwind v3 output, then copy, download, share the URL, or pipe it to another tool.
Key Benefits
- A genuinely interactive, resizable container — see breakpoints fire instead of imagining them
- Live "active breakpoint" indicator that updates as you drag, driven by a ResizeObserver
- Unlimited @container breakpoints with min-width, max-width, labels, and per-range CSS
- Reorder and delete breakpoints, with first-class unbounded (Any) min/max widths
- Four ready presets: card stack-to-row, sidebar-or-stack, fluid typography, and product grid
- Exports plain CSS, nested SCSS, Tailwind v4 (built-in), and Tailwind v3 (plugin) usage
- Built-in cqw/cqh/cqi/cqb/cqmin/cqmax units reference and a shareable, browser-only URL
Common Use Cases
- Building a card component that adapts to a sidebar, a wide hero, or a tight grid cell
- Designing a layout that switches between a single column and a content-plus-sidebar grid
- Creating fluid headings sized with cqi so type scales with the container, not the viewport
- Prototyping a product grid that steps from one to three columns as space allows
- Migrating viewport media queries to component-scoped @container rules for reusable UI
Resize the container — this layout responds to the.cq-preview-childrules from your active @container breakpoint, not the viewport.
Drag the bottom-right handle or use the slider. Showingcontainer-type: inline-size
Container
Breakpoints (2)
- 1Min widthpxMax widthpx
- 2Active nowMin widthpxMax widthUnbounded
Presets
Copy, download, share, or pipe to another tool
/* 1. Establish the containment context on the parent. */
.card-container {
container-type: inline-size;
container-name: card;
}
/* Narrow → stacked */
@container card (min-width: 0px) and (max-width: 359px) {
.card {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
}
/* Wide → side-by-side */
@container card (min-width: 360px) {
.card {
display: grid;
grid-template-columns: 1fr 2fr;
gap: 1rem;
align-items: center;
}
}Container query units (cq*)
cqw1% of the query container’s widthcqh1% of the query container’s heightcqi1% of the container’s inline size (usually width)cqb1% of the container’s block size (usually height)cqminthe smaller of cqi and cqbcqmaxthe larger of cqi and cqbQuery the container, not the viewport
Container queries let a component adapt to the space it actually sits in, so the same card looks right in a sidebar, a wide hero, or a tight grid cell. Declare a containment context with container-type on the parent, then write @container blocks that re-style descendants by the container’s size. This tool gives you a real, resizable container so you can watch the breakpoints fire — then exports plain CSS, SCSS, Tailwind v4 (built-in @container) or Tailwind v3 (the @tailwindcss/container-queries plugin).
Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related guide
Related tools
- Component Name GeneratorTurn a description into ranked, kind-aware component names with a file scaffold and a name validator (casing, collisions, clarity)
- Skeleton Screen GeneratorBuild layout-matched skeleton loaders (card/list/article/table) with shimmer/pulse/wave and a live preview
- Spacing Scale CalculatorLinear, geometric, Fibonacci or modular spacing scales with a visual ruler preview and utility classes — export CSS, Tailwind v4, SCSS, JSON
- SVG to React ComponentConvert SVG to a clean TSX/JSX/React Native component — currentColor, prop spread, forwardRef, memo, live preview
- Transition & Easing StudioDrag a cubic-bezier curve, play it on a live demo, and export CSS, @keyframes, Tailwind, Framer, or WAAPI
- Mobile Breakpoint TesterTest breakpoints on a live ruler and generate media/container queries, SCSS mixins, and Tailwind config
A media query responds to the viewport (the whole browser window), while a container query responds to the size of a specific ancestor element — its container. That means the same component can lay itself out differently depending on the space it is placed in, so a card in a narrow sidebar and the same card in a wide main column can each pick the right layout without knowing the page width.
container-type establishes an element as a query container. inline-size makes only the inline dimension (usually width) queryable and is the most common choice because it avoids layout loops. size makes both width and height queryable, which you need for height-based @container rules but which requires the container to have a defined size. normal turns off size queries (the element can still be a container for style/scroll-state queries). This tool defaults to inline-size.

