A practical reference for Tailwind CSS 4 that lays out clear rules: never use var() in className, never use hex colors, and only reach for cn() when you actually have conditional logic or potential class conflicts. The decision tree at the top is genuinely helpful for figuring out whether you need className, style props, or the cn() utility. Also includes a smart pattern for chart libraries like Recharts that can't accept className, where you define color constants with var() for their props. The examples cover the usual suspects like flexbox, grid, and responsive design, but the real value is in the "never do this" sections that prevent common mistakes. Straightforward and opinionated in a good way.

skills.sh installs
279
GitHub stars
665
last updated
Aug 21, 2026

Install

$ npx -y skills add gentleman-programming/gentleman-skills --skill tailwind-4 --agent claude-code

Installs into .claude/skills of the current project.

Files

Styling Decision Tree

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

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

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

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

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

When to Use cn()

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

Sponsors

Details

Repository
github.com/gentleman-programming/gentleman-skills
Category
Frontend Development
First seen
Jun 3, 2026

More from gentleman-programming/gentleman-skills

All 13
1thedivergentai avatargodot-ui-containersthedivergentai/gd-agentic-skillsExpert blueprint for responsive UI layouts using Container nodes (HBoxContainer, VBoxContainer, GridContainer, MarginContainer, ScrollContainer, HFlowContainer,279skills.sh installs
2microsoft avatarcomponent-fixturesmicrosoft/vscodeUse when creating or updating component fixtures for screenshot testing, or when designing UI components to be fixture-friendly. Covers fixture file structure, 277skills.sh installs
3spences10 avatarsvelte-deploymentspences10/svelte-skills-kitSvelte deployment guidance. Use for adapters, Vite config, pnpm setup, library authoring, PWA, or production builds.251skills.sh installs
4gentleman-programming avatarzustand-5gentleman-programming/gentleman-skillsZustand 5 state management patterns. Trigger: When managing React state with Zustand.207skills.sh installs
5oguzhan18 avatarangular-testingoguzhan18/angular-ecosystem-skillsALWAYS use when writing tests for Angular applications, including unit tests, component tests, service tests, or E2E tests with Jasmine, Karma, Vitest, or Cypre197skills.sh installs
6personamanagmentlayer avatarreact-expertpersonamanagmentlayer/pclExpert-level React development with hooks, performance optimization, state management, and modern patterns197skills.sh installs