tailgopher is a tailwind command for Go projects. It compiles Tailwind CSS v4.
You do not install Node, npm, Bun, or Deno to run it.
The command is official @tailwindcss/cli
inside the Go process. The JS runs in goja.
Oxide and Lightning CSS run as official WASM in wazero.
This repo is not a Tailwind Labs product. See Relation to Tailwind CSS.
Go 1.24 and later can record a developer command in go.mod with a tool directive.
See Tool dependencies on go.dev.
This module sets go 1.27.0. go get -tool raises your module go line to
at least that version. The first fetch may download that toolchain.
To add the command to your module, run:
go get -tool github.com/lewtec/tailgopher/cmd/tailwind@latestgo.mod then contains a line like this:
tool github.com/lewtec/tailgopher/cmd/tailwind
To compile CSS from anywhere inside that module, run:
go tool tailwind -i input.css -o output.cssThe last path segment is tailwind, so go tool tailwind is enough when no
other recorded tool uses that name. The full package path also works:
go tool github.com/lewtec/tailgopher/cmd/tailwind -i input.css -o output.cssTo list recorded tools, run go tool with no arguments.
To upgrade the recorded command later, run:
go get -tool github.com/lewtec/tailgopher/cmd/tailwind@latestTo remove it, run:
go get -tool github.com/lewtec/tailgopher/cmd/tailwind@noneA typical module layout is:
myapp/
go.mod
generate.go
ui/
input.css
index.html
out.css
generate.go at the module root:
package myapp
//go:generate go tool tailwind -i ./ui/input.css -o ./ui/out.css --minifyThen run go generate ./... from the module root.
go generate starts the command in the directory of the source file.
With generate.go at the module root, -i and -o are relative to that root.
Commit out.css, or run go generate in CI before you ship the stylesheet.
Native @parcel/watcher does not load in this host. Use polling:
go tool tailwind -i input.css -o output.css --watch --pollThe command accepts official Tailwind v4 CSS. A minimal file is:
@import "tailwindcss";
@source "./index.html";@import "tailwindcss" loads the official theme and utilities from the
embedded bundle. @source names files the scanner reads for class candidates.
Paths are relative to the input CSS file.
The command writes one output CSS path (-o). The default is stdout (-).
For the CSS dialect, read the Tailwind CSS documentation.
The command contains a closed catalog. These @plugin names resolve:
| Name in CSS | What it is |
|---|---|
daisyui |
daisyUI |
daisyui/theme |
daisyUI theme tokens |
@tailwindcss/typography |
official Typography plugin |
Example:
@import "tailwindcss";
@plugin "daisyui";
@plugin "@tailwindcss/typography";
@source "./index.html";A name outside the catalog fails the same way official @tailwindcss/cli
fails an unresolved plugin. The command does not read your node_modules.
tailgopher does not reimplement the Tailwind design system. It hosts the
official compiler so a Go module can run it as go tool tailwind.
| Job | What runs |
|---|---|
Flags, @import, @source, @plugin |
official @tailwindcss/cli |
| Class scan | official Oxide (WASM) |
--minify and --optimize |
official Lightning CSS (WASM) |
| Process | one Go executable. No node on PATH |
The teal gopher at the top is this project's mark, from issue #2. The hair follows the official Tailwind wave.
Tailwind name and logos are trademarks of Tailwind Labs Inc. See the Tailwind brand page. This repo is not an official Tailwind Labs release.
These flags come from official @tailwindcss/cli. This command does not add
a second flag dialect.
| Flag | Meaning |
|---|---|
-i, --input |
Input CSS file |
-o, --output |
Output CSS file. Default: stdout (-) |
-w, --watch[=always] |
Rebuild when sources change. Prefer --poll in this host |
--poll[=ms] |
Watch by polling instead of filesystem events |
-m, --minify |
Optimize and minify the output CSS |
--optimize |
Optimize without minify |
--cwd |
Working directory. Default: . |
--map |
Write a source map |
--silent |
Suppress non-error output |
-h, --help |
Print official usage text |
Unknown flags and missing input fail with official CLI stderr and a non-zero exit.
To compile without a tool line in go.mod, run:
go run github.com/lewtec/tailgopher/cmd/tailwind@latest -i input.css -o output.cssgo run fetches the module into the module cache and runs it. It does not
install a command onto your PATH.
mise can pin the command in the project. Do not use
mise use -g. That writes a user-global pin.
Add this to the project mise.toml:
[tools]
"go:github.com/lewtec/tailgopher/cmd/tailwind" = "latest"Then run:
mise install
mise exec -- tailwind -i input.css -o output.cssmise installs into its own tool store for this project. After mise install,
a mise-activated shell in this directory also has tailwind on PATH.
A task can call go tool or go run instead of pinning the command:
[tasks.css]
run = "go tool tailwind -i ./ui/input.css -o ./ui/out.css --minify"Then run mise run css. See the mise Go backend.
- The process does not start
node,bun, ordeno. - The catalog is the only
@pluginsource. Operatornode_modulesis ignored. - Tailwind v3 JS config is out of scope.
- There is no importable Go
CompileAPI yet.
SPEC.md is the project specification.
Node and npm are for maintainers of this repo. Operators of the command do not need them.
- Install pinned tools with mise.
- Run
npm ci. - Run
go generate ./...to refresh the embedded bundle and WASM. - Run
go test ./....
mise run build writes bin/tailwind. mise run ci runs the checks this repo
uses before a release.
| Concept | Term this repo uses |
|---|---|
Person who runs tailwind |
operator |
| Person who changes this repo | maintainer |
| Official Tailwind v4 compile step | compile |
Closed set of @plugin names |
catalog |
JS file go generate writes |
bundle |
| Stylesheet the command writes | output CSS |
