prefer-container-queries
flornkm/skills · Agent Skill
Применяйте запросы контейнера Tailwind вместо точек разрыва viewport для адаптивных компонентов. Используйте при написании или проверке адаптивного кода Tailwind, когда компоненту необходимо адаптироваться к доступному пространству (карточки, боковые панели, списки, панели, все, что переиспользуется в разных макетах), или при миграции классов sm:/md:/lg: на варианты @container.
Перейти к установке ↓Обзор
| Автор | |
|---|---|
| Репозиторий | flornkm/skills ↗ |
| Папка скилла | prefer-container-queries |
| Звёзды | 115 |
| Форки | 7 |
| Файлы | 1 |
| Лицензия | MIT |
| Обновлён | 20 августа 2026 г. |
| Ссылки | Исходник скилла ↗ · Репозиторий ↗ |
Проверка Mozgi
Что мы нашли в файлах скилла. Подробности — по подписке.
Установка
Скилл — это папка с файлом SKILL.md. Выберите своего агента и скопируйте команды в терминал (macOS, Linux или Git Bash на Windows) в корне проекта.
Скопируйте промпт и вставьте в Claude, Codex или другого ассистента: он сам проверит скилл и подключит его.
Установи мне скилл «prefer-container-queries» с mozgi.io (https://mozgi.io/skills/flornkm-prefer-container-queries/). 1. Скачай архив: https://mozgi.io/skills/flornkm-prefer-container-queries/download Если не скачивается — возьми папку скилла из исходника: https://github.com/flornkm/skills/tree/main/skills/prefer-container-queries 2. Прочитай SKILL.md и остальные файлы. Проверь, что скилл безопасен: нет скрытых команд, отправки данных наружу или скриптов, которые делают не то, что описано. Если что-то подозрительно — остановись и скажи мне. 3. Положи папку «prefer-container-queries» в папку скиллов своего агента: .claude/skills/ для Claude Code, .agents/skills/ для Codex, .cursor/skills/ для Cursor, .gemini/skills/ для Gemini CLI. В проекте — внутри проекта, иначе в домашней папке (~/.claude/skills/ и т. п.). 4. Убедись, что получилось <папка скиллов>/prefer-container-queries/SKILL.md. 5. Коротко расскажи, что умеет этот скилл, и предложи попробовать его на моей задаче. Если какой-то шаг не можешь сделать сам — подскажи, что нажать или ввести.
git clone --depth 1 --branch main https://github.com/flornkm/skills.git /tmp/skills mkdir -p .claude/skills cp -r /tmp/skills/skills/prefer-container-queries .claude/skills/prefer-container-queries
Перезапустите Claude Code — скилл появится в списке, вызвать вручную: /prefer-container-queries. Для всех проектов сразу — папка ~/.claude/skills.
git clone --depth 1 --branch main https://github.com/flornkm/skills.git /tmp/skills mkdir -p .agents/skills cp -r /tmp/skills/skills/prefer-container-queries .agents/skills/prefer-container-queries
Codex ищет скиллы в .agents/skills от текущей папки до корня репозитория; вызвать вручную — /skills или $prefer-container-queries. Для всех проектов — ~/.agents/skills.
git clone --depth 1 --branch main https://github.com/flornkm/skills.git /tmp/skills mkdir -p .cursor/skills cp -r /tmp/skills/skills/prefer-container-queries .cursor/skills/prefer-container-queries
Cursor подхватит скилл при запуске; вызвать вручную — «/» в чате агента. Cursor также читает .claude/skills и .agents/skills. Для всех проектов — ~/.cursor/skills.
git clone --depth 1 --branch main https://github.com/flornkm/skills.git /tmp/skills mkdir -p .gemini/skills cp -r /tmp/skills/skills/prefer-container-queries .gemini/skills/prefer-container-queries
Gemini CLI сам предложит включить скилл, когда задача подходит, — вы подтверждаете. Для всех проектов — ~/.gemini/skills.
Просмотрите SKILL.md и сопутствующие файлы перед установкой. Клик по файлу — предпросмотр.
Содержимое SKILL.md
Оригинальный текст автора · только чтение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/sidebarplus@md/sidebar:flex-rowto 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-rowon 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@containerancestor. They silently never apply.@containerand 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.
Вопросы и ответы
Что делает скилл prefer-container-queries?
Применяйте запросы контейнера Tailwind вместо точек разрыва viewport для адаптивных компонентов. Используйте при написании или проверке адаптивного кода Tailwind, когда компоненту необходимо адаптироваться к доступному пространству (карточки, боковые панели, списки, панели, все, что переиспользуется в разных макетах), или при миграции классов sm:/md:/lg: на варианты @container.
Как установить prefer-container-queries?
Откройте блок «Установка» на этой странице и выберите своего агента — Claude Code, Codex, Cursor или Gemini CLI: там готовые команды, которые копируют папку скилла в нужное место. Либо скопируйте промпт из вкладки «Через ассистента» — ассистент сам проверит и подключит скилл.
С какими нейросетями работает prefer-container-queries?
Скиллы — это обычные инструкции в Markdown (формат Agent Skills), поэтому prefer-container-queries подходит любому агенту, который читает SKILL.md: Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode и другие. Модель загружает инструкции только когда задача подходит под описание скилла.
Скилл prefer-container-queries бесплатный?
Скилл опубликован автором flornkm в открытом доступе под лицензией MIT. Сам скилл ничего не стоит — вы платите только своему провайдеру нейросети за использованные токены.
Безопасно ли устанавливать скиллы?
Скилл — это инструкции, которые агент будет выполнять, поэтому перед установкой прочитайте SKILL.md и сопутствующие файлы. Скрипты из папки скилла запускаются только если их запустит агент — следите за тем, что он делает, и не давайте лишних прав.
Чем скилл отличается от MCP-сервера или плагина?
MCP-сервер и плагин дают модели новые инструменты — код, который выполняется и возвращает результат. Скилл даёт знания и порядок действий: как подходить к задаче, какие шаги делать и как выглядит хороший результат. Ему не нужен сервер или ключ API.