Agent skill UI design
Prefer Container Queries
Organize content through layout, alignment and responsive composition.
Install the skill
Run the command from your project root with Node.js and npm.
npx skills@latest add flornkm/skills --skill prefer-container-queries --agent claude-code --yesCheck this file in your project.claude/skills/prefer-container-queries/SKILL.md
Other ways to install
Choose an assistant interactively
npx skills@latest add flornkm/skills --skill prefer-container-queriesSelect your assistant and choose the project installation scope.
Official instructions
The tested Skills CLI 1.10.0 requires Node.js 22.20 or later. Detect the installed Tailwind major. The fixture verified v4.3.5 native queries and v3.4.19 with @tailwindcss/container-queries 0.1.1.
View operation manualWhat this skill helps with
- Organize content through layout, alignment and responsive composition.
Good for
- Composition and spacing
- Skill name
- prefer-container-queries
- Scenario
- Move an existing card off viewport breakpoints
- Deliverable
- A component migration, measured nested-container behavior and a checked page-level layout.
- Skill name
prefer-container-queries- Repository
flornkm/skills
Define a styling task with a visible result
A request with an unclear outcome
Change every md: to @md: in this route.
The thresholds differ, the nearest container may be a different element, and page regions can still need viewport sizing.
A workflow with observable results
- Locate the component's real width owner
- Move the card layout to its parent query
- Resize the container at a fixed viewport
Prefer Container Queries operation manual
Make a nested card query the layout region that owns its available width.
Replace the bracketed details with your own project and target.
Locate the component's real width owner
Trace viewport classes and nesting before choosing a breakpoint.
Prompt · Step 1Use prefer-container-queries to inspect [reused card] inside [sidebar and main area]. Report the Tailwind major and container support, list the card's viewport-based layout utilities, and identify which ancestor actually owns its width. Inspect nested @container declarations and explain whether a named container is needed. Measure the smallest width that fits the card contents.Move the card layout to its parent query
Use the measured threshold instead of swapping prefixes.
Prompt · Step 2Use prefer-container-queries to migrate [approved card layout] using [measured width]. Put @container on its width-owning parent and responsive variants on descendants. Where an intermediate container would change the target, give the owner a name and use the matching named variants. Keep the page grid's viewport rules for its global regions. In v3 confirm the project already includes the official container query plugin or ask before adding it.Resize the container at a fixed viewport
Observe nearest and named targets and verify both placements.
- A component layout changes at the intended container width.
- A named query bypasses a narrower nested container when needed.
Prompt · Step 3Use prefer-container-queries to verify [migrated local card]. Keep the same viewport and compare widths just below and above [content threshold] for the intended container. Then test [nested placement] and find which ancestor the mapped rule uses. Report emitted query, actual width and computed layout, plus whether desktop page regions still sit in the intended order.
Find the relevant rule
Point the assistant to the installed Skill and a specific issue.
The responsive class never activatesReference
- Command or reference
SKILL.md · Mistakes to catch in review- Examples
- Check whether the variant and container were accidentally put on the same element.
The wrong nested region triggers the queryReference
- Command or reference
SKILL.md · Variants- Examples
- Name the width owner and use that name in the descendant query.
Prefer Container Queries troubleshooting
Are md: and @md: the same width?
Their default v4 targets differ. The viewport md threshold is 48rem and container @md is 28rem. Read the project's configured values before mapping either.