Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
sergiodxa avatar

Frontend Tailwind Best Practices

  • 425 installs
  • 93 repo stars
  • Updated February 1, 2026
  • sergiodxa/agent-skills

frontend-tailwind-best-practices is an agent skill that enforces Tailwind CSS layout, responsive, and className conventions across 10 rules for developers building maintainable React or frontend components.

About

frontend-tailwind-best-practices in sergiodxa/agent-skills packages 10 Tailwind CSS rules for layout utilities, color schemes, className handling, affordances, and responsive design. Agents replace raw flex classes with custom v-stack, h-stack, z-stack, center, spacer, and circle utilities; prefer parent gap-* over child margins; switch stack direction at breakpoints; merge classNames with cn(); and use class-based dark variants. Rules cover responsive text scaling, pointer-coarse touch targets, ClassNameRecord types for multi-element components, and ui-button affordance classes. Impact labels mark layout-stack-utilities and color-schemes as CRITICAL priorities during code reviews. Anti-patterns explicitly ban flex flex-col, inline styles for responsive behavior, and hard-coded hex colors without design tokens. Developers reach for this skill when writing component styles, building responsive layouts, or refactoring className props in Tailwind frontends. Key files referenced include tailwind.config.js, global.css variables, tailwind.css utilities, and app/utils/cn.ts.

  • Token and theme extension
  • Component variant patterns
  • Responsive and state variants
  • Dark mode conventions
  • Purge-safe class lists

Frontend Tailwind Best Practices by the numbers

  • 425 all-time installs (skills.sh)
  • +6 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #651 of 2,245 Frontend Development skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/sergiodxa/agent-skills --skill frontend-tailwind-best-practices

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs425
repo stars93
Last updatedFebruary 1, 2026
Repositorysergiodxa/agent-skills

What are maintainable Tailwind CSS patterns for React?

Apply Tailwind CSS patterns for maintainable components, responsive layouts, and design-system-aligned styling in modern frontends.

Who is it for?

Frontend developers standardizing Tailwind component patterns in React apps that use custom stack utilities and cn() helpers.

Skip if: CSS-in-JS or vanilla CSS projects without Tailwind, or teams that do not use sergiodxa-style custom stack utilities.

When should I use this skill?

User writes Tailwind component styles, responsive layouts, className props, or asks for Tailwind CSS best practices.

What you get

Tailwind-styled components using stack utilities, cn() merges, responsive breakpoints, and design-token color schemes.

  • Convention-compliant component classNames

By the numbers

  • Covers 10 Tailwind CSS rules across layout, color, affordance, and responsive categories

Files

SKILL.mdMarkdownGitHub ↗

Tailwind CSS Best Practices

Styling patterns and conventions for frontend applications. Contains 10 rules covering layout utilities, affordances, color schemes, responsive design, and className handling.

When to Apply

Reference these guidelines when:

  • Writing component styles with Tailwind
  • Creating layouts (stacks, grids, centering)
  • Handling responsive design
  • Working with color schemes
  • Merging className props

Rules Summary

Layout Utilities (CRITICAL)

layout-stack-utilities - @rules/layout-stack-utilities.md

Use custom stack utilities instead of flex classes.

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

// Good
<div className="v-stack gap-4">
<div className="h-stack gap-4">

Available utilities:

  • v-stack - Vertical stack (flex column)
  • h-stack - Horizontal stack (flex row)
  • v-stack-reverse - Reversed vertical stack
  • h-stack-reverse - Reversed horizontal stack
  • z-stack - Overlapping stack (grid-based, centers children on top of each other)
  • center - Center content both horizontally and vertically
  • spacer - Flexible spacer that fills available space
  • circle - Perfect circle with aspect-ratio 1/1
layout-prefer-gaps - @rules/layout-prefer-gaps.md

Use gap-* on parents instead of child margins.

// Bad
<div>
  <Item className="mb-4" />
  <Item className="mb-4" />
</div>

// Good
<div className="flex flex-col gap-4">
  <Item />
  <Item />
</div>
layout-responsive-stacks - @rules/layout-responsive-stacks.md

Switch layout direction at breakpoints.

// Mobile: vertical, Desktop: horizontal
<div className="v-stack lg:h-stack gap-4">
  <main className="grow">...</main>
  <aside className="shrink-0 lg:w-80">...</aside>
</div>

// Mobile: horizontal, Desktop: vertical
<div className="h-stack md:v-stack">

Color Schemes (CRITICAL)

color-schemes - @rules/color-schemes.md

Use class-based color schemes with a custom dark variant.

<button className="rounded-full bg-gray-900 px-4 py-2 text-white dark:bg-gray-100 dark:text-gray-900">
  Toggle
</button>

className Handling (CRITICAL)

classname-cn-utility - @rules/classname-cn-utility.md

Always use cn() to merge classNames in components.

import { cn } from "~/lib/cn";

function Button({ className, variant }: Props) {
  return (
    <button
      className={cn(
        "base-classes",
        {
          "variant-primary": variant === "primary",
          "variant-secondary": variant === "secondary",
        },
        className, // external className always last
      )}
    />
  );
}
classname-prop-types - @rules/classname-prop-types.md

Use proper types for className props.

import type { ClassName, ClassNameRecord } from "~/lib/cn";

// Single element
type Props = {
  className?: ClassName;
};

// Multiple elements
type Props = {
  className?: ClassNameRecord<"root" | "label" | "input">;
};

// Usage
<Input className={{ root: "w-full", label: "font-bold" }} />;

Affordances (HIGH)

affordance-classes - @rules/affordance-classes.md

Define element-agnostic visual patterns that compose with utilities.

<label className="ui-button" htmlFor="document-upload">
  Choose file
</label>

Responsive Design (MEDIUM)

responsive-breakpoints - @rules/responsive-breakpoints.md

Use responsive prefixes with Tailwind defaults.

// Standard breakpoints (min-width)
<div className="px-4 md:px-8 lg:px-12">

// Show/hide with standard breakpoints
<div className="hidden md:block">Desktop only</div>
<div className="md:hidden">Mobile only</div>
responsive-text - @rules/responsive-text.md

Scale text responsively.

// Responsive font size
<h1 className="text-2xl md:text-3xl lg:text-4xl">

// Responsive line height with text
<p className="text-sm leading-5 md:text-base md:leading-6">
responsive-capabilities - @rules/responsive-capabilities.md

Design for input capabilities (pointer/hover) instead of device labels.

<button className="h-10 w-10 pointer-coarse:h-12 pointer-coarse:w-12">
  <Icon />
</button>

Anti-Patterns

Don'tDo
flex flex-colv-stack
flex flex-rowh-stack
flex items-center justify-centercenter
bg-gray-100bg-neutral-100
bg-[#hex]Use design tokens
className="..." without cn()cn("...", className)
Inline style for responsiveTailwind prefixes

Key Files

FilePurpose
tailwind.config.jsConfig, custom utilities, colors
app/styles/global.cssColor scheme CSS variables
app/styles/tailwind.cssAdditional utilities
app/utils/cn.tsclassName merge utility

Related skills

How it compares

Pick frontend-tailwind-best-practices for opinionated stack-utility conventions; pick generic CSS skills when not using Tailwind or custom v-stack/h-stack utilities.

FAQ

What layout utilities does frontend-tailwind-best-practices recommend?

frontend-tailwind-best-practices replaces flex flex-col and flex-row with v-stack and h-stack utilities, uses gap-* on parents, and applies z-stack, center, spacer, and circle for common layout patterns.

How should className props be handled?

frontend-tailwind-best-practices requires cn() for all className merges, external classNames passed last, and ClassNameRecord types when components expose multiple styled elements.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.