Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

tailwind-4 — Claude Code skill: Tailwind CSS 4 patterns

A skill that sets how the agent styles with Tailwind CSS 4: which classes go in className, when to use style, and when to build classes with cn().

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add prowler-cloud/prowler --skill tailwind-4 -a claude-code
Open on GitHub

What tailwind-4 does

The skill kicks in whenever the agent touches styles in a Tailwind CSS 4 project. Inside is a decision tree. Tailwind class exists? Write it in className. Value changes at runtime? Use the style prop. Conditional classes? Reach for cn().

Hard rules come with before-and-after snippets. No var(--...) and no hex colours in className, so bg-[#1e293b] turns into bg-slate-800. The cn() helper is described as a wrapper over clsx and tailwind-merge. Both packages have to be in the project already, because the skill installs nothing — check that first.

One section covers libraries that reject a className, Recharts among them: keep constants holding var() and pass them through the style and fill props. Layout patterns follow: flex, grid, spacing, typography, dark mode. Arbitrary values like w-[327px] are fine for one-off sizes, not for colours. If your project has no cn() yet, the conditional examples need rewriting against your own helper.

What it helps with

  • pick between className, style and cn() for one element
  • strip var() and hex colours out of className
  • merge conflicting utilities on a button variant
  • feed theme colours into Recharts props
  • drive a width or opacity value from state without arbitrary classes

Example prompts for the agent

  • Restyle the card with Tailwind 4 and drop the `var()` calls from `className`.
  • Build the button classes for the primary and secondary variants using `cn()`.
  • Set the Recharts axis and grid colours from the theme CSS variables.

How to install tailwind-4

1Skills CLI (Vercel)

npx skills add prowler-cloud/prowler --skill tailwind-4 -a claude-code

2Manually: put the files in place

~/.claude/skills/tailwind-4/SKILL.md

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

From the same set4

The whole set →

Similar

typeui-fundamentals typeui.sh Provides design principles for visual hierarchy, a 4-point spacing grid, typography, and WCAG rules. Useful when the project design system leaves a gap. Claude Code CX Codex Cursor +1 2,200installs react-native-brownfield-migration callstackincubator Guides incremental React Native or Expo adoption in native iOS and Android apps using @callstack/react-native-brownfield. Claude Code CX Codex Cursor +1 5,200installs ios-hig-design wondelai Skill guides you through designing native iOS interfaces that follow Apple's Human Interface Guidelines. Use it when you're building an iPhone or iPad app and want it to feel at home on the platform. Claude Code CX Codex Cursor +1 8,100installs engineering-skills Alireza Rezvani An engineering skill index for Claude Code that helps you select one specialist SKILL.md for the task at hand. It covers architecture, testing, DevOps, and data work. Claude Code 2,387installs threejs-game-ui-designer majidmanzarpour Skill for designing game UIs in Three.js: HUDs, menus, pause and win screens, responsive layout for mobile and desktop. Prevents overlaps, ensures readability, and keeps UI cohesive with game style. Claude Code CX Codex Cursor +1 3,300installs threejs-gameplay-systems majidmanzarpour Scaffolds and tunes playable Three.js browser games with Vite and TypeScript. Helps design core loops, handle input, camera motion, and Rapier physics. Claude Code CX Codex Cursor +1 3,300installs frontend-design official anthropics This skill guides intentional visual design for new interfaces and redesigns. Use it when a generic generated UI is not enough. Claude Code Claude.ai 1,025,790installs design-taste-frontend Leonxlnx This skill directs the design of public pages and work screens, then checks the result in a browser through screenshots. Use it when an interface feels generic or unfinished. Claude Code CX Codex Cursor +1 673,100installs

Questions about tailwind-4

How do I install tailwind-4 in Claude Code?

Run npx skills add prowler-cloud/prowler --skill tailwind-4 -a claude-code. The skill ends up at ~/.claude/skills/tailwind-4/SKILL.md.

What does the tailwind-4 skill do?

It gives the agent Tailwind CSS 4 rules: a decision tree across className, style and cn(), a ban on var() and hex colours in classes, and patterns for libraries that take no className.

What do the cn() examples need to work?

clsx and tailwind-merge installed in the project, plus the cn() function built from them. The skill shows how to wire it up, it does not add the dependencies.

Source text

SKILL.md · Apache-2.0
---
name: tailwind-4
description: >
  Tailwind CSS 4 patterns and best practices.
  Trigger: When styling with Tailwind (className, variants, cn()), especially when dynamic styling or CSS variables are involved (no var() in className).
license: Apache-2.0
metadata:
  author: prowler-cloud
  version: "1.0"
  scope: [root, ui]
  auto_invoke: "Working with Tailwind classes"
allowed-tools: Read, Edit, Write, Glob, Grep, Bash, WebFetch, WebSearch, Task
---

## Styling Decision Tree

```text
Tailwind class exists?  → className="..."
Dynamic value?          → style={{ width: `${x}%` }}
Conditional styles?     → cn("base", condition && "variant")
Static only?            → className="..." (no cn() needed)
Library can't use class?→ style prop with var() constants
```

## Critical Rules

### Never Use var() in className

```typescript
// ❌ NEVER: var() in className
<div className="bg-[var(--color-primary)]" />
<div className="text-[var(--text-color)]" />

// ✅ ALWAYS: Use Tailwind semantic classes
<div className="bg-primary" />
<div className="text-slate-400" />
```

### Never Use Hex Colors

```typescript
// ❌ NEVER: Hex colors in className
<p className="text-[#ffffff]" />
<div className="bg-[#1e293b]" />

// ✅ ALWAYS: Use Tailwind color classes
<p className="text-white" />
<div className="bg-slate-800" />
```

## The cn() Utility

```typescript
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}
```

### When to Use cn()

```typescript
// ✅ Conditional classes
<div className={cn("base-class", isActive && "active-class")} />

// ✅ Merging with potential conflicts
<button className={cn("px-4 py-2", className)} />  // className might override

// ✅ Multiple conditions
<div className={cn(
  "rounded-lg border",
  variant === "primary" && "bg-blue-500 text-white",
  variant === "secondary" && "bg-gray-200 text-gray-800",
  disabled && "opacity-50 cursor-not-allowed"
)} />
```

### When NOT to Use cn()

```typescript
// ❌ Static classes - unnecessary wrapper
<div className={cn("flex items-center gap-2")} />

// ✅ Just use className directly
<div className="flex items-center gap-2" />
```

## Style Constants for Charts/Libraries

When libraries don't accept className (like Recharts):

```typescript
// ✅ Constants with var() - ONLY for library props
const CHART_COLORS = {
  primary: "var(--color-primary)",
  secondary: "var(--color-secondary)",
  text: "var(--color-text)",
  gridLine: "var(--color-border)",
};

// Usage with Recharts (can't use className)
<XAxis tick={{ fill: CHART_COLORS.text }} />
<CartesianGrid stroke={CHART_COLORS.gridLine} />
```

## Dynamic Values

```typescript
// ✅ style prop for truly dynamic values
<div style={{ width: `${percentage}%` }} />
<div style={{ opacity: isVisible ? 1 : 0 }} />

// ✅ CSS custom properties for theming
<div style={{ "--progress": `${value}%` } as React.CSSProperties} />
```

## Common Patterns

### Flexbox

```typescript
<div className="flex items-center justify-between gap-4" />
<div className="flex flex-col gap-2" />
<div className="inline-flex items-center" />
```

### Grid

```typescript
<div className="grid grid-cols-3 gap-4" />
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6" />
```

### Spacing

```typescript
// Padding
<div className="p-4" />           // All sides
<div className="px-4 py-2" />     // Horizontal, vertical
<div className="pt-4 pb-2" />     // Top, bottom

// Margin
<div className="m-4" />
<div className="mx-auto" />       // Center horizontally
<div className="mt-8 mb-4" />
```

### Typography

```typescript
<h1 className="text-2xl font-bold text-white" />
<p className="text-sm text-slate-400" />
<span className="text-xs font-medium uppercase tracking-wide" />
```

### Borders & Shadows

```typescript
<div className="rounded-lg border border-slate-700" />
<div className="rounded-full shadow-lg" />
<div className="ring-2 ring-blue-500 ring-offset-2" />
```

### States

```typescript
<button className="hover:bg-blue-600 focus:ring-2 active:scale-95" />
<input className="focus:border-blue-500 focus:outline-none" />
<div className="group-hover:opacity-100" />
```

### Responsive

```typescript
<div className="w-full md:w-1/2 lg:w-1/3" />
<div className="hidden md:block" />
<div className="text-sm md:text-base lg:text-lg" />
```

### Dark Mode

```typescript
<div className="bg-white dark:bg-slate-900" />
<p className="text-gray-900 dark:text-white" />
```

## Arbitrary Values (Escape Hatch)

```typescript
// ✅ OK for one-off values not in design system
<div className="w-[327px]" />
<div className="top-[117px]" />
<div className="grid-cols-[1fr_2fr_1fr]" />

// ❌ Don't use for colors - use theme instead
<div className="bg-[#1e293b]" />  // NO
```

© prowler-cloud · Apache-2.0 · prowler-cloud/prowler

See also

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