Loading...
Loading...
This skill should be used when the user asks to "style with Tailwind", "add Tailwind classes", "fix Tailwind styles", "use tailwind-variants", "add animations with tw-animate-css", "configure Tailwind v4", "migrate to Tailwind v4", or mentions Tailwind utilities, CSS classes, responsive design, dark mode, gradients, design tokens, or CSS Modules.
npx skill4agent add paulrberg/agent-skills tailwind-csstailwind.config.ts@import "tailwindcss"@theme { }@theme static { }@utility@custom-variant@import "tailwindcss";
@theme {
--color-brand: oklch(0.72 0.11 178);
--font-display: "Inter", sans-serif;
--spacing-edge: 1.5rem;
}@theme--color-brandbg-brandtext-brandborder-brandeslint-plugin-better-tailwindcssno-conflicting-classesno-unknown-classesenforce-canonical-classesenforce-shorthand-classesno-deprecated-classesno-duplicate-classesno-unnecessary-whitespace// ❌ Bad: separate padding
<div className="px-6 py-6">
// ✅ Good: shorthand
<div className="p-6">// ❌ Bad: separate width/height
<div className="w-6 h-6">
// ✅ Good: size utility
<div className="size-6">gapspace-xspace-ygapspace-*// ✅ Good: gap handles wrapping
<div className="flex gap-4">
// ❌ Bad: breaks when items wrap
<div className="flex space-x-4">size-*w-*h-*// ✅ Good: concise
<div className="size-16">
// ❌ Bad: redundant
<div className="w-16 h-16">min-h-dvhmin-h-screendvhvh// ✅ Good: works on mobile Safari
<main className="min-h-dvh">
// ❌ Bad: buggy on mobile Safari
<main className="min-h-screen">// ✅ Good: top margin
<div className="mt-4">
// ❌ Avoid: bottom margin (unless needed)
<div className="mb-4">:last-child// ✅ Good: padding on parent
<section className="pb-8">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</section>
// ❌ Avoid: margin on children
<section>
<div className="mb-4">Item 1</div>
<div className="mb-4">Item 2</div>
<div>Item 3</div>
</section>// ✅ Good: semantic container size
<div className="max-w-2xl">
// ❌ Avoid: arbitrary pixel value
<div className="max-w-[672px]">leading-*text-{size}/{leading}// ✅ Good: combined size and line height
<p className="text-base/7">
// ❌ Bad: separate utilities
<p className="text-base leading-7">| Class | Size |
|---|---|
| 12px |
| 14px |
| 16px |
| 18px |
| 20px |
*-opacity-*// ✅ Good: opacity modifier
<div className="bg-red-500/60">
// ❌ Bad: removed in v4
<div className="bg-red-500 bg-opacity-60">@theme// ✅ Good: theme token
<div className="bg-brand">
// ❌ Avoid: arbitrary hex (check theme first)
<div className="bg-[#4f46e5]">| v3 | v4 (equivalent) | Size |
|---|---|---|
| | 2px |
| | 4px |
| | 6px |
| | 8px |
bg-linear-*bg-gradient-*// ✅ Good: v4 syntax
<div className="bg-linear-to-r from-blue-500 to-purple-500">
// ❌ Bad: removed in v4
<div className="bg-gradient-to-r from-blue-500 to-purple-500">bg-radialbg-conic<div className="bg-radial from-blue-500 to-purple-500">
<div className="bg-conic from-red-500 via-yellow-500 to-green-500">@theme// ✅ Good: predefined scale
<div className="ml-4">
// ❌ Avoid: arbitrary pixel value
<div className="ml-[16px]">cnclsxtailwind-mergecnconst CARD_BASE = cn("fixed classes")cn("base", condition && "conditional")cn(baseClasses, className)cn("p-4", "p-6")"p-6"cnclassNameclassName="fixed classes"// ✅ Good: static string in className
<button className="rounded-lg px-4 py-2 font-medium bg-blue-600">
// ✅ Good: static constant with cn
const CARD_BASE = cn("rounded-lg border border-gray-300 p-4");
<div className={CARD_BASE} />
// ✅ Good: conditional with cn
<button className={cn(
"rounded-lg px-4 py-2 font-medium",
isActive ? "bg-blue-600" : "bg-gray-700",
disabled && "opacity-50"
)} />
// ❌ Bad: unnecessary cn for static className attribute
<button className={cn("rounded-lg px-4 py-2 font-medium")} />Image// ✅ Good: Tailwind units
<Image src={src} alt={alt} className="size-16" />
<Image src={src} alt={alt} className="w-24 h-auto" />
// ❌ Bad: pixel values
<Image src={src} alt={alt} width={64} height={64} />@themez-(--z-*)// ✅ Good: theme z-index value
<div className="z-(--z-modal)">
<div className="z-(--z-sticky)">
// ❌ Bad: arbitrary z-index numbers
<div className="z-[100]">
<div className="z-[9999]">@theme {
--z-base: 0;
--z-sticky: 10;
--z-modal: 100;
--z-tooltip: 1000;
}dark:// ✅ Good: light mode first, then dark override
<div className="bg-white text-gray-900 dark:bg-gray-900 dark:text-white">
// ❌ Avoid: dark mode first (less readable)
<div className="dark:bg-gray-900 dark:text-white bg-white text-gray-900">.module.css@reference "#tailwind";/* component.module.css */
@reference "#tailwind";
.component {
/* Complex CSS that can't be expressed with Tailwind utilities */
/* Can still use Tailwind utilities and theme tokens */
}references/tailwind-variants.md@themetv()tailwind-variantsimport { tv } from "tailwind-variants";
const button = tv({
base: "rounded-lg px-4 py-2 font-medium",
variants: {
color: {
primary: "bg-blue-600 text-white",
secondary: "bg-gray-600 text-white",
},
size: {
sm: "text-sm",
md: "text-base",
lg: "text-lg",
},
},
});references/tailwind-v4-rules.mdbg-linear-*bg-gradient-*bg-my-colorbg-[--var-my-color]@theme@theme/20/50// ✅ Good: theme token with opacity
<div className="bg-brand/20 text-brand">
// ❌ Avoid: arbitrary hex
<div className="bg-[#4f46e5]/20 text-[#4f46e5]">references/tw-animate-css.mdanimate-inanimate-out[0.625rem]2.5// Enter: fade + slide up
<div className="fade-in slide-in-from-bottom-4 duration-300 animate-in">
// Exit: fade + slide down
<div className="fade-out slide-out-to-bottom-4 duration-200 animate-out">| Aspect | Pattern |
|---|---|
| Configuration | CSS-only: |
| Gradients | |
| Opacity | Modifier syntax: |
| Line Height | Modifier syntax: |
| CSS Variables | |
| CSS Modules | |
| Class Merging | |
| Viewport | |
| Component Variants | |
| Animations | |
| V4 Rules | |
references/tailwind-v4-rules.mdreferences/tailwind-variants.mdreferences/tw-animate-css.md