home / skills / fusengine / agents / tailwindcss-core

This skill helps you configure Tailwind CSS v4.1 directly in CSS with directives, enabling a CSS-first workflow without a tailwind.config.js.

npx playbooks add skill fusengine/agents --skill tailwindcss-core

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
3.7 KB
---
name: tailwindcss-core
description: "Configuration and directives Tailwind CSS v4.1. @theme, @import, @source, @utility, @variant, @apply, @config. CSS-first mode without tailwind.config.js."
user-invocable: false
---

# Tailwind CSS Core v4.1

## Overview

Tailwind CSS v4.1 introduces a **CSS-first** approach that eliminates the need for a traditional `tailwind.config.js` file. All configuration is now done directly in your CSS files via specialized directives.

## Key Concepts

### 1. @import "tailwindcss"

Entry point to load Tailwind CSS. Place at the beginning of your main CSS file.

```css
@import "tailwindcss";
```

This directive automatically loads:
- Base utilities
- Responsive variants
- Layers (theme, base, components, utilities)

### 2. @theme

Directive to define or customize theme values via CSS custom properties.

```css
@theme {
  --color-primary: #3b82f6;
  --color-secondary: #ef4444;
  --spacing-custom: 2.5rem;
  --radius-lg: 1rem;
}
```

Variables are accessible in generated utilities:
- `--color-*` → classes `bg-primary`, `text-primary`, etc.
- `--spacing-*` → classes `p-custom`, `m-custom`, etc.
- `--radius-*` → classes `rounded-lg`, etc.

### 3. @source

Directive to include additional source files with glob patterns.

```css
@source "./routes/**/*.{ts,tsx}";
@source "./components/**/*.{tsx,jsx}";
@source "../packages/ui/src/**/*.{ts,tsx}";
```

Tailwind will scan these files to generate utilities used in your project.

### 4. @utility and @variant

Directives to create custom utilities and variants.

```css
@utility truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@variant group-hover {
  .group:hover &
}
```

### 5. @apply

Directive to apply Tailwind classes in your custom CSS rules.

```css
.btn {
  @apply px-4 py-2 rounded-lg font-semibold;
}

.btn-primary {
  @apply bg-blue-500 text-white hover:bg-blue-600;
}
```

### 6. @config

Directive to load external configuration if needed.

```css
@config "./tailwind.config.js";
```

(Optional in v4.1, mainly used for backward compatibility)

## Dark Mode

Dark mode configuration in Tailwind v4.1:

```css
@import "tailwindcss";

/* Use system preference */
@variant dark (&:is(.dark *));
```

Or via manual class:

```css
@variant dark (&.dark);
```

## Responsive Breakpoints

Breakpoints are defined via `@theme`:

```css
@theme {
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
}
```

Responsive variants are used with utilities:

```html
<div class="text-sm md:text-base lg:text-lg"></div>
```

## Layer Hierarchy

```css
@layer theme, base, components, utilities;

@import "tailwindcss";

/* Your customizations */
@layer components {
  .btn { @apply px-4 py-2 rounded; }
}

@layer utilities {
  .text-shadow { text-shadow: 0 2px 4px rgba(0,0,0,0.1); }
}
```

## Plugin Integration

Load Tailwind plugins:

```css
@import "tailwindcss";
@plugin "flowbite/plugin";
@source "../node_modules/flowbite";
```

## Specificity Order

In CSS-first, import and declaration order determines specificity:

1. `@import "tailwindcss"` - Base utilities
2. `@theme { ... }` - Theme variables
3. `@layer components { ... }` - Custom components
4. `@layer utilities { ... }` - Custom utilities

## CSS-first Mode Benefits

- No complex JavaScript config file
- Type-safe via CSS variables
- Declarative and readable configuration
- Better integration with CSS preprocessors
- Simplified maintenance for large projects

## Detailed References

See specific files for:
- `theme.md` - Complete theme variable configuration
- `directives.md` - Syntax and examples of all directives
- `config.md` - Advanced configuration and use cases

Overview

This skill provides a CSS-first implementation of Tailwind CSS v4.1, enabling full configuration and customization directly inside CSS files using directives like @theme, @utility, @variant, @apply, and @config. It removes the need for a tailwind.config.js by turning theme values into CSS custom properties and exposing them to generated utilities. The skill emphasizes predictable import and layer ordering and supports scanning project sources to generate only the utilities you use.

How this skill works

You declare Tailwind entry and extensions inside your CSS: import the core with @import "tailwindcss", define design tokens with @theme, and add custom utilities or variants using @utility and @variant. @source globs tell the generator which files to scan for used classes, so output is minimal and project-specific. Optional @config and @plugin directives support legacy JS configs and third-party plugins when needed.

When to use it

  • When you prefer a CSS-first workflow without maintaining tailwind.config.js
  • For projects that need type-safe design tokens using CSS custom properties
  • When you want declarative theme and breakpoint definitions colocated with styles
  • If you need scoped custom utilities, variants, or layers defined alongside CSS
  • When integrating Tailwind into CSS preprocessors or mono-repos with many source paths

Best practices

  • Place @import "tailwindcss" at the top of your main stylesheet to ensure correct base utility ordering
  • Define all tokens inside a single @theme block for predictable naming and reuse
  • Use @source with precise glob patterns to limit scanning and keep build output small
  • Organize rules with @layer theme, base, components, utilities to control specificity
  • Prefer @apply for reusable component rules but keep utility definitions small and focused

Example use cases

  • A design system that exposes color, spacing, and radius tokens as CSS variables for multiple packages
  • A React or Next.js app where CSS files declare source globs to generate only used utilities
  • Rapid prototyping where developers edit theme tokens directly in CSS without touching JS config
  • Adding custom utilities like text-shadow or truncate with @utility for consistent reuse
  • Enabling dark mode with a dedicated @variant to support system or class-based toggles

FAQ

Do I still need tailwind.config.js?

No — v4.1 supports full configuration via CSS directives, though @config is available for backward compatibility if you need existing JS config.

How are breakpoints defined?

Define breakpoints as CSS variables inside @theme (e.g., --breakpoint-md: 768px) and use responsive utility prefixes as usual.