Installation
Requirements
Section titled “Requirements”- Go 1.26+
- templ CLI (install)
- Tailwind CSS 4.x+
- HTMX 2.x (optional, for the
htmxpackage) GOEXPERIMENT=jsonv2environment variable (until Go 1.27 makes it stable)
Install
Section titled “Install”Run this in your project directory:
go get github.com/larsartmann/templ-components@latestTailwind CSS Setup
Section titled “Tailwind CSS Setup”Since this is a Go module (not an npm package), you need to vendor the dependency so Tailwind can scan the .templ source files for class names.
go mod vendorThen in your CSS entry point:
@import "tailwindcss";
/* Scan templ-components for class names */@source "../vendor/github.com/larsartmann/templ-components";
/* Enable class-based dark mode toggle */@custom-variant dark (&:where(.dark, .dark *));Build with the Tailwind CLI:
tailwindcss -i app.css -o styles.css --minifyIf your project uses BuildFlow, the tailwind-build provider handles vendoring + scanning automatically.
Verify Installation
Section titled “Verify Installation”go list -m github.com/larsartmann/templ-componentsNext Steps
Section titled “Next Steps”- Follow the Quick Start for a complete page example
- Learn about Theming to customize colors
- See HTMX Integration for server-rendered interactivity