tailwindcss

module
v0.0.0-...-6d7d20a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: MIT

README

TailwindCSS Example

Demonstrates how to integrate TailwindCSS with Datapages using a custom watcher that rebuilds output.css whenever .templ files or input.css change.

How It Works

The datapages.yaml defines a custom watcher:

custom-watchers:
  - name: "TailwindCSS"
    include:
      - "app/**/*.templ"
      - "input.tw.css"
    cmd: "npx tailwindcss -i ./input.tw.css -o ./app/static/output.css"
    fail-on-error: true
    requires: reload

Whenever a watched file changes, Datapages runs the tailwindcss command to regenerate app/static/output.css, then triggers a browser reload.

TailwindCSS v4 uses a CSS-first configuration. input.css imports the framework and declares which source files to scan for utility classes:

@import "tailwindcss";
@source "./app/**/*.templ";

No tailwind.config.js is needed.

Prerequisites

Install TailwindCSS v4. The package.json pins the version:

# Option A: npm (version pinned in package.json)
# In v4 the CLI is a separate package: @tailwindcss/cli
npm install
npx tailwindcss --version  # verify

# Option B: standalone binary (no Node.js needed)
# Download from https://github.com/tailwindlabs/tailwindcss/releases/latest
# and place `tailwindcss` in your PATH.

Run in Dev Mode

datapages watch

The watcher proxy starts at http://localhost:7331. The app itself listens on http://localhost:8080 (configure via HOST/PORT env vars or .env).

Build for Production

# Generate the final CSS
npx tailwindcss -i ./input.tw.css -o ./app/static/output.css --minify

# Build the server binary
go build -o server ./cmd/server/

Directories

Path Synopsis
templ: version: v0.3.1001
templ: version: v0.3.1001
cmd
server command
action
Package action provides generators for datastar action attribute expressions.
Package action provides generators for datastar action attribute expressions.
assets
Package assets provides constants for embedded static file serving.
Package assets provides constants for embedded static file serving.
href
Package href provides generators for datastar anchor hypertext references.
Package href provides generators for datastar anchor hypertext references.
httperr
Package httperr provides sentinel errors for action handlers.
Package httperr provides sentinel errors for action handlers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL