Skip to main content
skill CX Codex

frontend-tailwind-best-practices — Claude Code skill for Tailwind CSS

Ten Tailwind CSS rules for frontend work: stack utilities, gap-based spacing, dark color schemes and className merging. Useful when an agent writes component styles.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add sergiodxa/agent-skills --skill frontend-tailwind-best-practices -a claude-code
Open on GitHub

What frontend-tailwind-best-practices does

The skill packs 10 rules for styling frontend apps with Tailwind: layout utilities, affordances, color schemes, responsive design and className handling. Each rule lives in its own file under @rules/ with bad and good code samples.

Layout is where it changes agent output most. Instead of flex flex-col gap-4 you get v-stack gap-4, instead of flex flex-row — h-stack, and centering becomes center. There is also z-stack, spacer and circle. Spacing goes on the parent as gap-* rather than as margins on every child, and stack direction flips at breakpoints: v-stack lg:h-stack.

For className, the skill insists on the cn() helper from ~/lib/cn, with the external class always last. Prop types come from the same module: ClassName and ClassNameRecord. Dark mode is class-based with a custom dark variant. One catch — v-stack and friends are not stock Tailwind. You have to declare them in tailwind.config.js and app/styles/tailwind.css, or the classes do nothing.

What it helps with

  • build layouts from vertical and horizontal stacks without hand-written flex
  • put spacing on the parent with gap instead of margins on children
  • flip stack direction at a breakpoint
  • implement dark mode with classes rather than system preference
  • merge an external className with a component's base classes

Example prompts for the agent

  • build a product card with Tailwind following the skill rules
  • rewrite this component: drop flex flex-col and use v-stack
  • add dark mode to the button with the dark variant and cn()

How to install frontend-tailwind-best-practices

1Skills CLI (Vercel)

npx skills add sergiodxa/agent-skills --skill frontend-tailwind-best-practices -a claude-code

2Manually: put the files in place

~/.claude/skills/frontend-tailwind-best-practices/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/frontend-tailwind-best-practices/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about frontend-tailwind-best-practices

How do I install frontend-tailwind-best-practices in Claude?

Run npx skills add sergiodxa/agent-skills --skill frontend-tailwind-best-practices -a claude-code. The skill lands in ~/.claude/skills/frontend-tailwind-best-practices/SKILL.md.

What does frontend-tailwind-best-practices do?

It gives the agent 10 Tailwind conventions: stack utilities, gap-based spacing, responsive breakpoints, class-based dark mode and className merging through cn().

Does it need project setup?

Yes. Utilities like v-stack, h-stack and center are declared in tailwind.config.js and app/styles/tailwind.css, and cn() lives in app/utils/cn.ts.

Source text

SKILL.md · MIT
---
name: frontend-tailwind-best-practices
description: Tailwind CSS patterns and conventions for frontend apps. Use when writing component styles, layouts, or working with CSS classes.
---

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

```tsx
// 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.

```tsx
// 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.

```tsx
// 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.

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

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

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

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

```tsx
// 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.

```tsx
// 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.

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

## Anti-Patterns

| Don't                              | Do                     |
| ---------------------------------- | ---------------------- |
| `flex flex-col`                    | `v-stack`              |
| `flex flex-row`                    | `h-stack`              |
| `flex items-center justify-center` | `center`               |
| `bg-gray-100`                      | `bg-neutral-100`       |
| `bg-[#hex]`                        | Use design tokens      |
| `className="..."` without `cn()`   | `cn("...", className)` |
| Inline `style` for responsive      | Tailwind prefixes      |

## Key Files

| File                      | Purpose                          |
| ------------------------- | -------------------------------- |
| `tailwind.config.js`      | Config, custom utilities, colors |
| `app/styles/global.css`   | Color scheme CSS variables       |
| `app/styles/tailwind.css` | Additional utilities             |
| `app/utils/cn.ts`         | className merge utility          |

© sergiodxa · MIT · sergiodxa/agent-skills

Similar skills

Everything for Frontend and UI →

From the same set5

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor