Skip to content
ofershapPublic

About

Pure-Go Tailwind v3 utility engine: compile CSS from Go source files as an importable library or go install-able CLI. Built for templ and Go web pipelines.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

gailwind

gailwind - Tailwind utility CSS, compiled in Go

Your Go web app uses Tailwind classes, and now your CSS build step depends on fetching a platform binary - or installing Node in a Go pipeline.

gailwind compiles Tailwind v3 utility CSS from your Go source files with a pure-Go engine. Import it as a library in your templ handler, code generator or build tool, or go install the CLI. One dependency, managed by go itself.

$ gailwind -o app.css './templates/**/*.templ' './web/**/*.html'
$ gailwind -minify -strict -o app.css index.html
/* app.css starts with the real v3.4.19 preflight, then only the utilities you used: */
*, ::before, ::after {
  --tw-border-spacing-x: 0;
  ...
}
.hover\:bg-blue-600:hover {
  --tw-bg-opacity: 1;
  background-color: rgb(37 99 235 / var(--tw-bg-opacity, 1));
}

Classes gailwind can't compile are printed to stderr, never silently dropped. -strict turns that into a failed build, so your pipeline breaks loudly instead of shipping unstyled markup.

Install

CLI:

go install github.com/ofershap/gailwind/cmd/gailwind@latest

Library:

go get github.com/ofershap/gailwind
css, report := gailwind.Generate(source1, source2)
// report.Unknown lists class-attribute tokens gailwind did not generate

What it does

  • Compiles the Tailwind v3.4.19 default-theme core utility set: layout, spacing, sizing, flex/grid, typography, colors, borders, effects, transforms, interactivity, transitions and animations.
  • Variants: pseudo-classes (hover, focus-visible, first...), group/peer, sm-2xl, dark, orientation, motion and print.
  • Arbitrary values: w-[17px], bg-[#bada55].
  • Includes the real v3.4.19 preflight (embedded verbatim, Tailwind Labs, MIT - see licenses/) and the container component, so output matches @tailwind base; @tailwind components; @tailwind utilities;. -no-preflight opts out.
  • Orders rules the way v3 does, so cascade behavior matches what Tailwind produces for the same classes.

What it doesn't do

  • Not a full Tailwind port. No plugins, no custom themes or config files, no @apply. Gradients, filters, space-*/divide-*, and ring color/offset sub-utilities are not implemented.
  • Class-based dark mode is out; dark: compiles to @media (prefers-color-scheme: dark), v3's default.
  • The fidelity numbers below cover gailwind's implemented-feature corpus, not a percentage of Tailwind.

Measured fidelity

Verified against the real [email protected] CLI, not self-reported:

  • 290/290 rules - 100% declaration match, 0 order inversions on the implemented-feature corpus (testdata/corpus.html, ~200 classes across every implemented family, including variant stacks, negatives and arbitrary values). Reproduce with parity/parity.py.
  • Real-template check: on the unmodified tailwindtoolbox Landing-Page, gailwind's full output (preflight + container + utilities) matches the real v3.4.19 build on 206/206 flattened rules - 100% declaration match. Of 169 class-attribute candidates, 160 generated; the 9 reported unknowns are v2-era classes real v3.4.19 doesn't generate either, plus the template's own custom classes. Element-anchored side-by-side renders are visually identical.

How it works

  1. Extract candidate classes from source text (Tailwind-style candidate regex).
  2. Compile each candidate against the embedded v3.4.19 default theme into the same declarations v3 emits, including its rgb(R G B / var(--tw-*-opacity, 1)) color form, --tw-shadow triplets, vendor-prefixed fallbacks and keyframes.
  3. Order rules the way v3's variant offsets order them (verified empirically against probe outputs).

Q&A

How do I use Tailwind CSS with Go and templ? Point gailwind at your .templ and .html files and write the output to your static directory. The official Tailwind CLI already ships a standalone binary; gailwind is for when you want the compiler as a Go library inside your own tooling, or a CLI installed and pinned by go install like the rest of your Go tools.
Can I generate Tailwind CSS without Node? Yes. gailwind's engine, CLI and tests are pure Go. (Development used the official CLI once to generate reference fixtures; the shipped code embeds the results with license and provenance.)
Is gailwind a full Tailwind replacement? No. It is the v3.4.19 default-theme core utility set with the variants listed above, measured against the real CLI on its implemented-feature corpus. No plugins, custom themes or @apply. If you need the full framework, use the official Tailwind CLI.
What happens when I use a class gailwind doesn't know? It is printed to stderr and skipped; -strict exits 1. Unknown detection only flags tokens you actually wrote in a class attribute, so SVG path data and prose don't produce noise.
Does it watch files? No -watch flag; re-run the command. It's pure Go with no startup tax, so re-runs are fast.
Can I use my own theme? No. The v3.4.19 default theme is the contract.

Contributing

Issues and PRs welcome - see CONTRIBUTING.md. Please report security issues privately per SECURITY.md.

More projects: gitshow · real-browser-mcp · cursor-usage-tracker · mcp-server-markdown · readme-builder · grok-bot-skills · mashov-parent-brief


Author

Made by ofershap

LinkedIn GitHub Blog


README built with README Builder

License

MIT © Ofer Shapira. The embedded Tailwind v3.4.19 preflight is MIT, Tailwind Labs - see licenses/.

About

Pure-Go Tailwind v3 utility engine: compile CSS from Go source files as an importable library or go install-able CLI. Built for templ and Go web pipelines.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages