prefer-container-queries

flornkm/skills · Agent Skill

Tailwind konteynır sorgularını, responsiv bileşenler için görünüm noktası kesme noktaları yerine uygulayın. Tailwind'i yazarken veya responsiv kodu doğrularken, bir bileşenin (kartlar, yan paneller, listeler, paneller, farklı düzenlerde yeniden kullanılan her şey) kullanılabilir alana uyum sağlaması gerektiğinde veya sm:/md:/lg: sınıflarını @container seçeneklerine geçirmek için kullanın.

Kuruluma geç ↓

Genel bakış

YayıncıflornkmTopluluk
Depoflornkm/skills ↗
Skill klasörüprefer-container-queries
Yıldız115
Fork7
Dosyalar1
LisansMIT
Son güncelleme20 Ağustos 2026
BağlantılarSkill kaynağı ↗ · Depo ↗

Mozgi kontrolü

Skill dosyalarında bulduklarımız. Ayrıntılar abonelikle.

Güvenlik
düşük risk · belirgin risk bulunamadı — tam rapor ayrıntıları gösterir
Uyumluluk
yalnızca talimatlar — çoğu ajanla çalışır
Benzer skiller
139 benzer skill bulundu
Abonelikte ayrıca

Kurulum

Skill, SKILL.md dosyası içeren bir klasördür. Ajanınızı seçin ve komutları proje kökünde bir terminalde çalıştırın (macOS, Linux veya Windows'ta Git Bash).

Promptu Claude, Codex veya başka bir asistana yapıştırın: skill'i inceleyip sizin için kuracaktır.

Install the “prefer-container-queries” skill from mozgi.io (https://mozgi.io/skills/flornkm-prefer-container-queries/) for me.

1. Download the archive: https://mozgi.io/skills/flornkm-prefer-container-queries/download
   If it fails, take the skill folder from the source: https://github.com/flornkm/skills/tree/main/skills/prefer-container-queries
2. Read SKILL.md and the other files. Check the skill is safe: no hidden commands, no sending data elsewhere, no scripts doing something other than described. If anything looks suspicious, stop and tell me.
3. Put the “prefer-container-queries” folder into your agent's skills folder: .claude/skills/ for Claude Code, .agents/skills/ for Codex, .cursor/skills/ for Cursor, .gemini/skills/ for Gemini CLI. Inside the project if we are in one, otherwise in the home folder (~/.claude/skills/ etc.).
4. Make sure <skills folder>/prefer-container-queries/SKILL.md exists.
5. Briefly tell me what this skill does and offer to try it on my task.

If you cannot do a step yourself, tell me what to click or type.

Kaynak dosyaları

1 dosya ZIP indir

Kurulumdan önce SKILL.md ve eşlik eden dosyaları inceleyin. Önizleme için dosyaya tıklayın.

SKILL.md içeriği

Yazarın orijinal metni · salt okunur

Prefer Container Queries

Components should respond to the space they are in, not to the viewport. A card that lives in a sidebar has maybe 300px of width even on a huge screen, and a viewport breakpoint like md:flex-row will get that wrong every time. Container queries fix this: the component asks "how wide am I?" instead of "how wide is the window?".

When writing responsive Tailwind, default to container queries. Viewport breakpoints are the exception, not the rule.

How it works

Mark the parent as a container, then use @-prefixed variants on its children:

<div class="@container">
  <div class="flex flex-col @md:flex-row @md:gap-6">
    <img class="w-full @md:w-48" />
    <div class="@md:flex-1">...</div>
  </div>
</div>

@md: here means "when the container is at least 28rem wide", regardless of viewport size. This card works in a sidebar, a modal, and a full-width grid without changing a single class.

Two rules that trip people up:

1. The @container class goes on the parent. The @md: variants go on descendants. An element cannot query its own size.

2. Container variants respond to the nearest ancestor with @container. If styles are not applying, check which container you are actually querying.

Variants

Tailwind v4 ships container queries in core. The sizes:

| Variant | Min width |

| --- | --- |

| @3xs | 16rem (256px) |

| @2xs | 18rem (288px) |

| @xs | 20rem (320px) |

| @sm | 24rem (384px) |

| @md | 28rem (448px) |

| @lg | 32rem (512px) |

| @xl | 36rem (576px) |

| @2xl | 42rem (672px) |

| @3xl | 48rem (768px) |

| @4xl | 56rem (896px) |

| @5xl | 64rem (1024px) |

| @6xl | 72rem (1152px) |

| @7xl | 80rem (1280px) |

Also available:

  • @max-md: styles below a container size.
  • @min-[475px]: arbitrary values when the scale does not fit.
  • @container/sidebar plus @md/sidebar:flex-row to name a container and query it from deeper in the tree, past other containers.

The full docs for this can be found here ↗.

On Tailwind v3, the same syntax needs the @tailwindcss/container-queries plugin. Check the Tailwind version before writing classes.

When viewport breakpoints are still right

Do not convert these:

  • Page-level layout. The overall grid, whether the sidebar exists at all, header and navigation behavior. These genuinely depend on the viewport.
  • Fixed or sticky elements positioned relative to the viewport, like a bottom bar that becomes a side rail.
  • Global typography scale tied to screen size.

Everything inside those layout regions, meaning cards, forms, media objects, stat blocks, table-to-list switches, should use container queries.

Migrating existing code

1. Find the component's responsive classes (sm:, md:, lg:).

2. Add @container to the component's root or the wrapper that owns the available space.

3. Replace viewport variants with the container variant that matches the actual width where the layout should change. Do not map md: to @md: blindly; md is 768px of viewport, @md is 448px of container. Resize the container, not the window, to find the real breakpoint.

4. Test the component in its narrowest real context (sidebar, drawer, small grid cell), not just at mobile viewport widths.

Mistakes to catch in review

  • md:flex-row on a component that is rendered inside a sidebar or modal. It will stay stacked or break depending on the viewport, not its actual space.
  • @md: variants used with no @container ancestor. They silently never apply.
  • @container and a @md: variant on the same element. The element cannot query itself; move the variant to a child or the container class to the parent.
  • A component that only looks right at the exact spot it was built for. If moving it to a different column breaks it, it is viewport-coupled.

Sık sorulan sorular

prefer-container-queries skill'i ne yapar?

Tailwind konteynır sorgularını, responsiv bileşenler için görünüm noktası kesme noktaları yerine uygulayın. Tailwind'i yazarken veya responsiv kodu doğrularken, bir bileşenin (kartlar, yan paneller, listeler, paneller, farklı düzenlerde yeniden kullanılan her şey) kullanılabilir alana uyum sağlaması gerektiğinde veya sm:/md:/lg: sınıflarını @container seçeneklerine geçirmek için kullanın.

prefer-container-queries nasıl kurulur?

Bu sayfadaki “Kurulum” bölümünü açın ve ajanınızı seçin — Claude Code, Codex, Cursor veya Gemini CLI: skill klasörünü doğru yere kopyalayan hazır komutlar orada. Ya da “Asistanla” sekmesindeki promptu kopyalayın; asistan skill'i inceleyip kuracaktır.

prefer-container-queries hangi yapay zekâlarla çalışır?

Skill'ler düz Markdown talimatlarıdır (Agent Skills formatı), bu yüzden prefer-container-queries SKILL.md okuyan her ajanla çalışır: Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode ve diğerleri. Model talimatları yalnızca görev skill açıklamasına uyduğunda yükler.

prefer-container-queries ücretsiz mi?

Skill, flornkm tarafından açık olarak yayımlandı (MIT lisansı). Skill'in kendisi ücretsizdir — yalnızca kullandığınız token'lar için yapay zekâ sağlayıcınıza ödeme yaparsınız.

Skill kurmak güvenli mi?

Skill, ajanınızın izleyeceği talimatlardır; kurmadan önce SKILL.md ve eşlik eden dosyaları okuyun. Skill klasöründeki betikler yalnızca ajanınız çalıştırırsa çalışır — ne yaptığını izleyin ve gereksiz izin vermeyin.

Skill, MCP sunucusu veya eklentiden nasıl farklıdır?

MCP sunucusu veya eklenti modele yeni araçlar verir — çalışıp sonuç döndüren kod. Skill ise bilgi ve süreç verir: göreve nasıl yaklaşılacağı, hangi adımların izleneceği ve iyi sonucun neye benzediği. Sunucu veya API anahtarı gerekmez.

Benzer skiller

Tüm skiller →