# Tailwind v4 without Node

Every page compiles only the classes it uses, in PHP.

## One setting, no build step

Set `tailwind.enabled` in `blockstudio.json` and write utility classes in any template. On each frontend request Blockstudio collects the class candidates in the finished HTML and compiles exactly those with TailwindPHP, a PHP port of Tailwind CSS 4.3.

There is no Node.js, no CLI, and no watcher. Classes from block templates, theme templates, plugins, and `the_content` all count, because the whole page is scanned.

[Enabling Tailwind](https://blockstudio.dev/docs/tailwind/#enabling-tailwind)

blockstudio.json

```
{
  "tailwind": {
    "enabled": true
  }
}
```

## No Node runtime

TailwindPHP compiles in the request; there is nothing to build or deploy.

## Tailwind 4.3 utilities

Utilities, variants, arbitrary values, and directives from Tailwind CSS 4.3.

## Whole-page scan

Classes count wherever they appear in the final HTML.

## Cached by class set

Pages that use the same classes share one compiled file.

## CSS-first config

@theme tokens and @utility rules in blockstudio.json or a filter.

## Live editor preview

A bundled browser build previews classes while you type.

## Linked output

One content-hashed stylesheet that browsers and edge caches can keep.

## Typography and forms

The two official plugins are ported to PHP and load with @plugin.

## Configured in CSS

Tailwind v4 is configured with CSS, not a JavaScript file. Put `@theme` tokens, `@utility` rules, and layers in `tailwind.config`, or append them through the `blockstudio/tailwind/css` filter when they span several lines.

The official typography and forms plugins are ported to PHP and load with `@plugin`. Plugins that only exist as JavaScript packages do not run, because nothing executes Node.

Class aliases are `@apply` rules inside `@layer utilities`, such as a `.btn` built from padding and radius utilities. They compile on the frontend and in the editor preview alike.

[Configuration](https://blockstudio.dev/docs/tailwind/#configuration)

functions.php

```
add_filter('blockstudio/tailwind/css', function (string $css): string {
  return $css . '
    @plugin "@tailwindcss/typography";
    @theme { --color-brand: #4f46e5; }
    @utility container-narrow {
      max-width: 48rem;
      margin-inline: auto;
    }
  ';
});
```

## Classes as a field

Give a `classes` field `"tailwind": true` and editors get autocomplete from the full class list, with a bundled Tailwind browser build previewing each change in the canvas.

With `assets.reset.enabled`, the canvas also restores display and position utilities such as `flex`, `grid`, and `sticky` that editor wrapper rules would otherwise override.

[Classes field type](https://blockstudio.dev/docs/tailwind/#classes-field-type)

block.json

```
{
  "name": "acme/hero",
  "title": "Hero",
  "blockstudio": {
    "attributes": [
      {
        "id": "classes",
        "type": "classes",
        "label": "Classes",
        "tailwind": true,
        "default": "bg-white text-gray-900"
      }
    ]
  }
}
```

## One stylesheet, cached by class set

Compiled CSS is cached on disk under a key built from the page’s sorted class candidates and the CSS input, so nonces and timestamps never bust it and pages with the same classes share one file.

Inline output is the default. `"output": "link"` emits that cache file as a content-hashed stylesheet instead. Measured on a local copy of this site on October 8, 2026, it took the home page HTML from 451,648 to 296,379 bytes.

When `cache.path` points at a private volume, Blockstudio falls back to inline CSS unless the `blockstudio/files/url` filter returns a public URL for the `tailwind` scope, such as a CDN host.

[Frontend output](https://blockstudio.dev/docs/tailwind/#frontend-output)

blockstudio.json

```
{
  "tailwind": {
    "enabled": true,
    "output": "link"
  }
}
```

## Merge classes in PHP

`bs_tw_merge()` resolves conflicting utilities so an authored class wins over a default. `bs_tw_variants()` returns a variant callable with base classes, variants, defaults, and compound variants.

Both use the TailwindPHP engine Blockstudio already bundles, so a theme needs no copy of its own.

[Template helpers](https://blockstudio.dev/docs/tailwind/#template-composition-helpers)

index.php

```
echo bs_tw_merge('px-2 text-sm', 'px-4');
// text-sm px-4

$button = bs_tw_variants([
  'base' => 'inline-flex items-center',
  'variants' => [
    'size' => ['sm' => 'h-8 px-3', 'lg' => 'h-12 px-6'],
  ],
  'defaultVariants' => ['size' => 'sm'],
]);

echo $button(['size' => 'lg', 'class' => 'rounded']);
```

## Purge on demand

Runtime_Cache::purge(‘tailwind’) clears the compiled CSS, and the next request compiles it again.

## Optional page buffer

A site that uses neither Tailwind nor block assets can turn the page buffer off with the blockstudio/buffer/enabled filter.

## Isolated per source

With a logical discovery source, the selected source and runtime context join the cache namespace, so last-good CSS never leaks between previews.

## Canonical layer order

Theme, base, components, then utilities, as in Tailwind CSS, so later layers override earlier ones.

Plus

## The official extension kit

Premium site templates, AI system instructions, and a private Discord community. One-time purchase, lifetime updates.

- 500+ site templates
- AI system instructions
- Lifetime updates
- Private Discord community

[Get Plus](https://blockstudio.dev/plus/)
