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.
CLI:
go install github.com/ofershap/gailwind/cmd/gailwind@latestLibrary:
go get github.com/ofershap/gailwindcss, report := gailwind.Generate(source1, source2)
// report.Unknown lists class-attribute tokens gailwind did not generate- 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-preflightopts out. - Orders rules the way v3 does, so cascade behavior matches what Tailwind produces for the same classes.
- Not a full Tailwind port. No plugins, no custom themes or config files, no
@apply. Gradients, filters,space-*/divide-*, andringcolor/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.
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 withparity/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.
- Extract candidate classes from source text (Tailwind-style candidate regex).
- 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-shadowtriplets, vendor-prefixed fallbacks and keyframes. - Order rules the way v3's variant offsets order them (verified empirically against probe outputs).
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.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
README built with README Builder
MIT © Ofer Shapira. The embedded Tailwind v3.4.19 preflight is MIT, Tailwind Labs - see licenses/.
