T templcn/ui
CLITerminal

Go tooling for component management

This is a Go + templ port inspired by shadcn/ui. Instead of an npm CLI, you use standard Go and templ toolchain commands to install and manage components.

Get the module
Install templcn components into your Go module.

Copy the UI package into your project with the CLI:

templcn add button

Or if you're developing this repository in a Go workspace, add the local module path:

go work use ./ui
Generate templ files
Run the templ code generator after any .templ file change.

Generate all _templ.go files from .templ sources:

templ generate

Or watch for changes during development:

templ generate --watch
Build & run
Standard Go build commands work as expected.

Run for development

go run main.go

Build a production binary

go build -o ./bin/app .

Generate the static docs site

go run ./cmd/generate --output ./bin/site

Run all tests

go test ./...
Using components
Import the ui package and call components directly.

Each UI component is a regular Go function that returns a templ.Component. Use them with the @ call syntax:

package views

import "templcn/ui"

templ MyPage() {
	@ui.Button(ui.ButtonProps{Label: "Click me"})

	@ui.Card(ui.DOMProps{}) {
		@ui.CardHeader(ui.DOMProps{}) {
			@ui.CardTitle(ui.DOMProps{}) { <span>Hello</span> }
		}
		@ui.CardContent(ui.DOMProps{}) {
			<p>Card body content here.</p>
		}
	}
}