Frontend Style & Layout Patterns

VerifiedSafe

Applies consistent styling and layout patterns using Tailwind v4. Covers the Section Compound Pattern for structuring pages, spacing selection methods (flex gap, space-y/x, spacer divs), CLS-free responsive images with aspect-ratio containers, and migration from Tailwind v3 to v4. Useful when building page layouts, choosing spacing, implementing responsive images, or updating from v3 to v4.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude CodeCursorWindsurfCopilotCodex
#tailwind-v4#layout-patterns#spacing#responsive-images

Recommended for

Automated summary

Applies consistent Tailwind v4 styling and layout patterns for frontend development, including section structure, spacing selection, CLS-free responsive images, and v3-to-v4 migration.

Strengths

  • Promotes explicit layout structure at the usage site
  • Provides a decision flow for choosing spacing methods
  • Prevents CLS with aspect-ratio-based responsive images
  • Covers Tailwind v4 class changes for migration

Limitations

  • Requires familiarity with Tailwind v4 syntax
  • Does not cover advanced responsive breakpoints
  • Assumes use of Tailwind utility classes exclusively
When to use it

Use when building new page layouts or migrating existing Tailwind v3 code to v4.

When not to use it

Avoid when using a different CSS framework or when layout is handled by a UI library.

Security analysis

Safe
Quality score92/100

This skill provides frontend styling patterns and Tailwind v4 guidance. It does not instruct any actions that could compromise security, such as executing shell commands, accessing network resources, or manipulating files. The content is purely informational and educational.

No concerns found

How this analysis is made

Examples

Apply Section Compound Pattern
Create a page layout for an order list page using the Section Compound Pattern with Tailwind v4. Include a sticky header, main content area with filters and list, and a sticky footer with action buttons.
Choose spacing method
I have a flex container with three child components. How should I add 24px spacing between them using Tailwind v4? Should I use gap, space-y, or a spacer div?
Add responsive image with CLS prevention
Add a responsive product thumbnail image with an aspect ratio of 4:3. It should be centered, fill its container, and not cause layout shift (CLS). Use lazy loading if it's below the fold.

name: frontend-style-layout description: 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.

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.

// ✅ 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:

<div className="flex flex-col gap-4">
  <OrderCard />
  <OrderCard />
</div>

space-y / space-x — Sibling elements with consistent spacing:

<ul className="space-y-3">
  <li>
    <ReviewItem />
  </li>
  <li>
    <ReviewItem />
  </li>
</ul>

Explicit spacer div — Single specific gap (e.g., from design spec):

<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.

// ✅ 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

/* ❌ 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

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/frontend-style-layout-patterns-mm5t8aev/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/frontend-style-layout-patterns-mm5t8aev' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/frontend-style-layout-patterns-mm5t8aev/download' --output '.skill-downloads/frontend-style-layout-patterns-mm5t8aev/SKILL.md.part' && mv '.skill-downloads/frontend-style-layout-patterns-mm5t8aev/SKILL.md.part' '.skill-downloads/frontend-style-layout-patterns-mm5t8aev/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/frontend-style-layout-patterns-mm5t8aev/SKILL.md' && test -s '.skill-downloads/frontend-style-layout-patterns-mm5t8aev/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/frontend-style-layout' && cp -R '.skill-downloads/frontend-style-layout-patterns-mm5t8aev' '.claude/skills/frontend-style-layout'

Cursor
test -f '.skill-downloads/frontend-style-layout-patterns-mm5t8aev/SKILL.md' && test -s '.skill-downloads/frontend-style-layout-patterns-mm5t8aev/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/frontend-style-layout' && cp -R '.skill-downloads/frontend-style-layout-patterns-mm5t8aev' '.cursor/skills/frontend-style-layout'

Codex
test -f '.skill-downloads/frontend-style-layout-patterns-mm5t8aev/SKILL.md' && test -s '.skill-downloads/frontend-style-layout-patterns-mm5t8aev/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/frontend-style-layout' && cp -R '.skill-downloads/frontend-style-layout-patterns-mm5t8aev' '.agents/skills/frontend-style-layout'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/frontend-style-layout-patterns-mm5t8aev'

openskills read 'frontend-style-layout-patterns-mm5t8aev'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/frontend-style-layout-patterns-mm5t8aev/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills