css-container-queries

Style components with CSS container queries based on container size.

1|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/Thomashighbaugh/opencode --skill css-container-queries-thomashighbaugh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: css-container-queries
Source: https://github.com/Thomashighbaugh/opencode/tree/main/skills/css-container-queries
Command: npx skills add https://github.com/Thomashighbaugh/opencode --skill css-container-queries-thomashighbaugh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Components that rely on viewport-based media queries often break when reused in different layout contexts, forcing designers and engineers to duplicate variants or add layout-specific logic. This Skill helps make components self-contained so they adapt to the size of their immediate container, improving portability and reducing layout coupling.

Core Features & Use Cases

  • Container-based styling: Use CSS container queries to change component layout and typography based on container width or size rather than the viewport.
  • Tailwind integration: Apply Tailwind's container utilities and named containers to enable container-aware variants within utility-driven markup.
  • Practical patterns: Includes recommended patterns for cards, responsive grids, and mixed container + media query strategies to balance page-level and component-level responsiveness.
  • Progressive enhancement: Guidance for feature-detecting container support and providing fallbacks for older browsers, plus a testing checklist for multiple container sizes.
  • Real-world example: Convert a reusable card component so it displays stacked content in narrow sidebar contexts and a two-column layout in wider container contexts.

Quick Start

Convert a card component to use CSS container queries and Tailwind container utilities so it adapts its layout based on its parent's width rather than the viewport.

Frequently Asked Questions about css-container-queries

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

FAQPage Schema
How do I make a component responsive to its container size instead of the viewport?

Use CSS container queries by defining container-type and container-name on the parent element, enabling styles to adapt based on container width rather than viewport size for improved component portability.

Does Tailwind CSS support container queries for responsive components?

Tailwind CSS supports container queries through its container utilities and named containers, allowing you to apply container-aware variants directly within utility-driven markup for responsive components.

Why do my reusable card components break when placed in different layout contexts?

Viewport-based media queries cause components to break in different contexts because they ignore the immediate container size. Container queries solve this by making components self-contained and adaptable to their parent's width.

How do I provide fallbacks for browsers lacking container query support?

Implement progressive enhancement by feature-detecting container query support and providing fallback styles, ensuring components remain functional across older browsers that lack native container query capabilities.

What is the best way to handle responsive grids using container queries?

Apply container-type to grid cells and use @container variants to adjust component layout and typography based on container width, balancing page-level media queries with component-level responsiveness for optimal grid behavior.

Can I mix container queries with viewport media queries in the same design system?

You can combine container queries with viewport media queries by using container queries for component-level adaptations and media queries for page-level layouts, creating a balanced responsive strategy across your design system.