All skills
asyrafhussin avatar

/tailwind-best-practices

@481a693

Tailwind CSS patterns and conventions. Use when writing responsive designs, implementing dark mode, creating reusable component styles, configuring Tailwind, or migrating from v3 to v4. Triggers on tasks involving Tailwind classes, responsive design, dark mode, CSS styling, or "migrate to Tailwind v4".

Use this Skill: https://skilld.dev/gh/asyrafhussin/agent-skills/tailwind-best-practices

This session only. Nothing lands on disk.

rulesv4-installation.md

≈646 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Why It Matters

Tailwind CSS v4 ships as a dedicated Vite plugin (@tailwindcss/vite) or PostCSS plugin (@tailwindcss/postcss). The old tailwindcss + postcss + autoprefixer setup no longer applies. Configuration moves entirely out of JavaScript and into CSS via @import "tailwindcss".

Incorrect

# ❌ v3 install — wrong for v4
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
// ❌ v3 postcss.config.js — not needed in v4 with Vite
module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
}
/* ❌ v3 directives — do not use in v4 */
@tailwind base;
@tailwind components;
@tailwind utilities;

Correct

With Vite (recommended)

npm install tailwindcss @tailwindcss/vite
// vite.config.ts
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'

export default defineConfig({
  plugins: [tailwindcss()],
})
/* app.css — single import replaces all three @tailwind directives */
@import "tailwindcss";

With PostCSS (Laravel Mix, Webpack, etc.)

npm install tailwindcss @tailwindcss/postcss
// postcss.config.js
module.exports = {
  plugins: {
    '@tailwindcss/postcss': {},
  },
}
/* app.css */
@import "tailwindcss";

Limiting scan scope with @source

By default, v4 auto-detects your template files. Override with @source if needed:

@import "tailwindcss";

/* Only scan specific paths */
@source "./resources/js/**/*.{ts,tsx}";
@source "./resources/views/**/*.blade.php";

/* Exclude paths from scanning */
@source not "./resources/js/legacy/**";

Importing without emitting CSS with @reference

Use @reference when you need access to theme values or @apply in a secondary CSS file without duplicating Tailwind's output:

/* components/card.css — not the main entry point */
@reference "tailwindcss";

.card {
  @apply rounded-lg bg-white shadow-sm dark:bg-gray-800;
}

Recommended Patterns

Scenario Tool Install
React + Vite @tailwindcss/vite npm i tailwindcss @tailwindcss/vite
Laravel + Vite @tailwindcss/vite npm i tailwindcss @tailwindcss/vite
PostCSS-based @tailwindcss/postcss npm i tailwindcss @tailwindcss/postcss
CLI only @tailwindcss/cli npm i tailwindcss @tailwindcss/cli

Reference: https://tailwindcss.com/docs/installation

Source: SKILL.md on GitHub

No alerts16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill is a comprehensive collection of best practices, rules, and code patterns for Tailwind CSS v3 and v4. It provides guidance on responsive design, dark mode, component architecture, and theme configuration. No security issues were detected in the instructions or provided code snippets.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    32 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 481a693. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago
Other metadata
metadata
{
  "author": "agent-skills",
  "version": "1.0.0",
  "tailwindVersion": "3.4+ / 4.0+"
}

README badge

README badge for asyrafhussin/agent-skills/tailwind-best-practices