frontend-style-layout
Apply consistent styling and layout patterns with Tailwind v4. Use when building page layouts, choosing spacing methods, implementing responsive images, or migrating Tailwind v3 classes to v4. Covers Section Compound Pattern, spacing selection, CLS-free responsive images, and v4 class changes.
Best use case
frontend-style-layout is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Apply consistent styling and layout patterns with Tailwind v4. Use when building page layouts, choosing spacing methods, implementing responsive images, or migrating Tailwind v3 classes to v4. Covers Section Compound Pattern, spacing selection, CLS-free responsive images, and v4 class changes.
Teams using frontend-style-layout should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/frontend-style-layout/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How frontend-style-layout Compares
| Feature / Agent | frontend-style-layout | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Apply consistent styling and layout patterns with Tailwind v4. Use when building page layouts, choosing spacing methods, implementing responsive images, or migrating Tailwind v3 classes to v4. Covers Section Compound Pattern, spacing selection, CLS-free responsive images, and v4 class changes.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Frontend Style & Layout Patterns
Tailwind v4 styling patterns for this project. Covers page structure, spacing, responsive images, and v3→v4 migration.
## 1. Section Compound Pattern
Express page layout structure explicitly using semantic HTML + Tailwind classes at the usage site.
```tsx
// ✅ Layout structure visible at a glance
const OrderListPage = () => (
<main className="min-h-screen flex flex-col">
<header className="sticky top-0 z-10 bg-white border-b border-gray-200">
<OrderListHeader />
</header>
<section className="flex-1 flex flex-col gap-4 px-4 py-6">
<OrderFilterBar />
<OrderList />
</section>
<footer className="sticky bottom-0 bg-white border-t border-gray-200 px-4 py-3">
<OrderListFooterActions />
</footer>
</main>
)
```
### What to Expose vs. Hide
| Expose at usage site | Hide in component |
| --------------------------------------- | ---------------------------------- |
| Layout structure (flex, grid, position) | Reusable styles (button variants) |
| Page-specific spacing and sizing | Internal implementation details |
| Semantic HTML structure | Complexity outside current concern |
- Reusable styles (buttons, cards) → abstract into components.
- Page layout → write directly at the usage site in `screens/` pages.
## 2. Spacing Selection Guide
### Three Methods
**flex gap** — Default for Flexbox containers:
```tsx
<div className="flex flex-col gap-4">
<OrderCard />
<OrderCard />
</div>
```
**space-y / space-x** — Sibling elements with consistent spacing:
```tsx
<ul className="space-y-3">
<li>
<ReviewItem />
</li>
<li>
<ReviewItem />
</li>
</ul>
```
**Explicit spacer div** — Single specific gap (e.g., from design spec):
```tsx
<div>
<OrderHeader />
<div className="h-8" /> {/* 32px explicit gap */}
<OrderContent />
</div>
```
### Decision Flow
```
Need spacing?
├── Inside Flexbox container? → flex gap
├── Repeating sibling spacing? → space-y / space-x
├── Single explicit gap (from design spec)? → spacer div
└── Complex conditional spacing? → individual margin/padding
```
### Notes
- Use gap inside flex containers to avoid margin collapsing.
## 3. Responsive Images — CLS Prevention
Use `aspect-ratio` + `relative` container to maintain original ratio responsively.
```tsx
// ✅ Basic responsive image
const Illustration = () => (
<div className="flex justify-center">
<div className="relative w-full aspect-[327/200]">
<img
src="/illustrations/order-complete.png"
alt="Order complete"
className="object-contain w-full h-full"
loading="eager"
/>
</div>
</div>
)
// ✅ With max-width constraint
const Thumbnail = ({ src, alt }: { src: string; alt: string }) => (
<div className="relative w-full max-w-sm aspect-square">
<img src={src} alt={alt} className="object-cover w-full h-full rounded-lg" loading="lazy" />
</div>
)
```
### Key Properties
| Property | Purpose |
| --------------------------------- | ------------------------------- |
| `relative` | Positioning anchor for children |
| `aspect-[W/H]` | Maintain ratio (prevents CLS) |
| `w-full` | Fill parent width |
| `object-contain` / `object-cover` | Image fit mode |
### Loading Strategy
- `loading="eager"`: Above-the-fold images (LCP optimization)
- `loading="lazy"`: Below-the-fold images (initial load optimization)
## 4. Tailwind v4 Class Changes
> This project uses **Tailwind v4**. Do NOT use v3 syntax.
### Import Syntax
```css
/* ❌ v3 (forbidden) */
@tailwind base;
@tailwind components;
@tailwind utilities;
/* ✅ v4 */
@import 'tailwindcss';
```
### Class Migration Table
| v3 (forbidden) | v4 (use this) |
| -------------- | ------------- |
| `shadow-sm` | `shadow-xs` |
| `shadow` | `shadow-sm` |
| `ring` | `ring-3` |
| `blur` | `blur-sm` |
| `rounded` | `rounded-sm` |
Reference: [Tailwind v4 Upgrade Guide](https://tailwindcss.com/docs/upgrade-guide)Related Skills
frontend-ui
Create aesthetically pleasing, visually distinctive frontend UIs using research-backed prompting strategies from Anthropic's frontend aesthetics cookbook
frontend-styleguide
Use when asked to create or edit style guides, design systems, component libraries, or update existing frontend components for web projects
frontend-governance
Enforces Contemplative design system and Anti-Slop protocols for all UI generation
frontend-design
Create distinctive, bold UI designs that avoid generic AI aesthetics. This skill should be used when users want frontend components with strong visual identity, creative typography, intentional color palettes, and production-grade animations - specifically to avoid the bland, safe, homogeneous "AI slop" that plagues most generated interfaces.
class-organization-and-layout
Organize class members in standard order, separate classes with blank lines, and maintain one-class-per-file structure. Use when designing class interfaces, implementing classes, organizing project files, or establishing OOP coding standards.
avalonia-layout-zafiro
Guidelines for modern Avalonia UI layout using Zafiro.Avalonia, emphasizing shared styles, generic components, and avoiding XAML redundancy.
audit-style
Audit and refactor CSS to comply with Game Loopers design system and BEM methodology
agent-sessions-layout
Agent Sessions workbench layout — covers the fixed layout structure, grid configuration, part visibility, editor modal, titlebar, sidebar footer, and implementation requirements. Use when implementing features or fixing issues in the Agent Sessions workbench layout.
37signals-rails-style
Apply 37signals/DHH Rails conventions when writing Ruby on Rails code. Use when building Rails applications, reviewing Rails code, or making architectural decisions. Covers various aspects of Rails application architecture, design and dependencies.
eos-style
Strunk & White style review using the 21 reminders from "Elements of Style" Chapter V. Use when editing prose, reviewing drafts, or improving writing clarity and tone.
academic-writing-style
Personalized academic writing assistant for university assignments in Chinese and English. Use when users need help writing/revising academic reports, project docs, technical analyses, research reviews, or case studies. Produces natural prose avoiding AI markers. Triggers: academic writing, assignment, report, technical analysis, research review, case study. | 个性化学术写作助手,适用于中英文大学作业。触发词:学术写作、作业、报告、技术分析、研究综述、案例研究、项目文档。
innozverse-api-style
Follow API development conventions including RESTful design, Fastify patterns, Zod validation, error handling, and versioning. Use when building API endpoints, adding routes, or working with API code.