PHPackages                             tailwindphp/tailwindphp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tailwindphp/tailwindphp

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tailwindphp/tailwindphp
=======================

A full port of TailwindCSS 4.x to PHP

v1.4.2(1mo ago)193.0k↓75.8%6[2 PRs](https://github.com/inline0/tailwindphp/pulls)1MITPHPPHP ^8.2CI passing

Since Dec 4Pushed 4w agoCompare

[ Source](https://github.com/inline0/tailwindphp)[ Packagist](https://packagist.org/packages/tailwindphp/tailwindphp)[ Docs](https://github.com/dnnsjsk/tailwindphp)[ RSS](/packages/tailwindphp-tailwindphp/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (20)Versions (15)Used By (1)

    ![TailwindPHP](./docs/public/logo-light.svg)

 A 1:1 port of TailwindCSS 4.x to PHP — generate Tailwind utility CSS with no Node.js and no build step.

 [![Tests](https://github.com/inline0/tailwindphp/actions/workflows/tests.yml/badge.svg)](https://github.com/inline0/tailwindphp/actions/workflows/tests.yml) [![Packagist](https://camo.githubusercontent.com/f3395d5a5f35f5d804610c9e9092677c013a0ac4a24b783253a1a73d3abdf2e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7461696c77696e647068702f7461696c77696e647068702e737667)](https://packagist.org/packages/tailwindphp/tailwindphp) [![license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/inline0/tailwindphp/blob/main/LICENSE)

---

What is TailwindPHP?
--------------------

[](#what-is-tailwindphp)

TailwindPHP is a 1:1 port of TailwindCSS 4.x to PHP. It scans your markup for class names and generates the exact same utility CSS that TailwindCSS produces — entirely in PHP, with no Node.js, no build step, and no extensions beyond a standard PHP 8.2+ build.

**The problem:** TailwindCSS is written in TypeScript and runs on Node.js. Any PHP project that wants Tailwind inherits a second runtime, an `npm install`, and a build step in CI and Docker. For WordPress plugins, framework packages, and apps that generate CSS at runtime, that's friction — or a dealbreaker.

**TailwindPHP solves this** by implementing the Tailwind compiler natively in PHP:

- The complete **TailwindCSS v4.3** surface — all 364 utilities, every variant (hover, focus, responsive, dark mode, container queries, arbitrary values), and byte-for-byte output
- The full directive set — `@import`, `@theme`, `@apply`, `@utility`, `@custom-variant`, `@layer`, `@plugin`, and `@source`
- Tailwind's CSS functions — `theme()`, `--theme()`, `--spacing()`, `--alpha()` — plus `color-mix()` → `oklab()` and the transforms Tailwind delegates to LightningCSS
- **Batteries included** — PHP ports of [clsx](https://github.com/lukeed/clsx), [tailwind-merge](https://github.com/dcastil/tailwind-merge), and [CVA](https://github.com/joe-bell/cva) as `cn()`, `merge()`, `join()`, and `variants()`
- **Plugins** — `@tailwindcss/typography` and `@tailwindcss/forms` ported in full, plus a PHP plugin API for your own
- A **CLI** (`bin/tailwindphp`) that mirrors `@tailwindcss/cli`, plus file-based caching and a CSS minifier
- **4,000+ tests** — output is verified against TailwindCSS's own test suites, extracted from the TypeScript source and re-run on every push

Quick Start
-----------

[](#quick-start)

```
composer require tailwindphp/tailwindphp
```

```
use TailwindPHP\tw;

// Generate CSS from markup — only the classes you actually use
$css = tw::generate('');

// Customize the theme with a CSS string
$css = tw::generate(
    '',
    '@import "tailwindcss"; @theme { --color-brand: #3b82f6; }'
);

// Inspect a class without rendering a full stylesheet
tw::computedProperties('p-4');      // ['padding' => '1rem']
tw::computedValue('text-blue-500'); // 'oklch(.546 .245 262.881)'
```

Build conditional class strings and resolve conflicts (clsx + tailwind-merge):

```
use function TailwindPHP\cn;

cn('px-2 py-1', 'px-4');             // 'py-1 px-4'
cn('btn', ['btn-primary' => true]);  // 'btn btn-primary'
```

Declarative component variants (CVA):

```
use function TailwindPHP\variants;

$button = variants([
    'base' => 'inline-flex items-center rounded-md font-medium',
    'variants' => [
        'intent' => ['primary' => 'bg-blue-500 text-white', 'ghost' => 'hover:bg-accent'],
        'size'   => ['sm' => 'h-9 px-3', 'lg' => 'h-11 px-8'],
    ],
    'defaultVariants' => ['intent' => 'primary', 'size' => 'sm'],
]);

$button(['size' => 'lg']); // 'inline-flex … bg-blue-500 text-white h-11 px-8'
```

CLI
---

[](#cli)

A drop-in port of `@tailwindcss/cli` — same options, no Node.js:

```
# Build CSS from an input file
./vendor/bin/tailwindphp -i ./src/app.css -o ./dist/styles.css

# Watch and rebuild on change
./vendor/bin/tailwindphp -i ./src/app.css -o ./dist/styles.css --watch

# Minify for production
./vendor/bin/tailwindphp -i ./src/app.css -o ./dist/styles.css --minify
```

Point `@source` at the templates to scan in your input CSS:

```
@import "tailwindcss";
@source "./templates";
```

Documentation
-------------

[](#documentation)

Full documentation lives at [tailwindphp.com](https://tailwindphp.com) (or in [`docs/`](./docs) if you're reading the repo).

- [Getting Started](./docs/content/docs/getting-started.mdx) — install and generate your first stylesheet
- [Usage](./docs/content/docs/usage/) — content scanning, theme, directives, imports, and `@source`
- [Class Utilities](./docs/content/docs/class-utilities/) — `cn()`, `merge()`, `join()`, and `variants()`
- [Plugins](./docs/content/docs/plugins/) — typography, forms, and writing your own
- [API](./docs/content/docs/api.mdx) — the full `tw` surface and the `TailwindCompiler` instance
- [CLI](./docs/content/docs/cli.mdx) — `bin/tailwindphp` reference
- [Advanced](./docs/content/docs/advanced/) — architecture, caching, and performance

Credits
-------

[](#credits)

TailwindPHP ports:

- [TailwindCSS](https://tailwindcss.com) by Tailwind Labs
- [clsx](https://github.com/lukeed/clsx) by Luke Edwards
- [tailwind-merge](https://github.com/dcastil/tailwind-merge) by Dany Castillo
- [CVA](https://github.com/joe-bell/cva) by Joe Bell

License
-------

[](#license)

MIT

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance92

Actively maintained with recent releases

Popularity33

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Total

14

Last Release

51d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dc81a975082b6843421de211768cfb67d8237bed4c972c9a1eaad46aac14b372?d=identicon)[dnnsjsk](/maintainers/dnnsjsk)

---

Top Contributors

[![dnnsjsk](https://avatars.githubusercontent.com/u/73965001?v=4)](https://github.com/dnnsjsk "dnnsjsk (225 commits)")

---

Tags

phpcsstailwindtailwindcssutility-css

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tailwindphp-tailwindphp/health.svg)

```
[![Health](https://phpackages.com/badges/tailwindphp-tailwindphp/health.svg)](https://phpackages.com/packages/tailwindphp-tailwindphp)
```

###  Alternatives

[yieldstudio/tailwind-merge-php

Merge Tailwind CSS classes without style conflicts

4975.4k1](/packages/yieldstudio-tailwind-merge-php)[gehrisandro/tailwind-merge-php

TailwindMerge for PHP merges multiple Tailwind CSS classes by automatically resolving conflicts between them

1391.8M12](/packages/gehrisandro-tailwind-merge-php)[arnolem/tailwindphp

TailwindPHP - use Tailwind CSS in your PHP projects (without npm)

1427.5k](/packages/arnolem-tailwindphp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
