using-container-queries

Configure Tailwind v4 container queries with @container and breakpoint utilities.

Updated Nov 21, 2025
One-click install
npx skills add https://github.com/djankies/claude-configs --skill using-container-queries
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-container-queries
Source: https://github.com/djankies/claude-configs/tree/main/tailwind-4/skills/using-container-queries
Command: npx skills add https://github.com/djankies/claude-configs --skill using-container-queries

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill teaches container queries in Tailwind v4, enabling components to adapt to their parent container size rather than viewport.

Core Features & Use Cases

  • Container Context: Use @container to make elements responsive to parent width.
  • Named Containers: Leverage @container/{name} and @{breakpoint}/{name}: utilities.
  • Portable Components: Build reusable widgets that scale with their container.

Quick Start

Wrap a component in a container and apply container-based utilities (e.g., @sm or @md variants) to child elements.

Frequently Asked Questions about using-container-queries

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do container queries make components responsive without relying on viewport size?

Container queries enable components to respond to their parent container's width rather than the viewport. Use @container to wrap a component, then apply container-based utilities like @sm, @md, @lg to child elements, allowing the same component to adapt across cards, dashboards, and grids regardless of screen size.

Can I use container queries with Tailwind to build truly portable UI components?

Yes. Container queries in Tailwind v4 let you create reusable widgets that scale with their container context. Apply @container to a parent and use @{breakpoint} utilities on children to build components that work in any layout—sidebar, grid cell, or embedded card—without viewport dependencies.

What's the difference between container queries and viewport media queries for responsive design?

Viewport media queries respond to screen size; container queries respond to parent container width. Container queries solve the limitation of viewport-dependent layouts by enabling components to adapt locally, making them portable across different container widths in the same page.

How do named containers work in Tailwind v4?

Named containers let you target specific parent containers with @container/{name} and @{breakpoint}/{name} utilities. This enables fine-grained control when multiple nested containers exist, allowing different child components to respond to different container contexts independently.

Can I combine container queries with viewport-based media queries in the same component?

Yes. Mixed container-viewport queries let you layer both approaches—use @container utilities for local responsiveness and standard media query utilities for global viewport changes. This hybrid approach balances portability with device-level adaptations.

What are the limitations of container queries when building responsive layouts?

Container queries require Tailwind v4 and modern browser support. They work best for component-level adaptation but cannot replace viewport queries for full-page layout shifts. Performance depends on container nesting depth—excessive nesting may impact rendering.