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 buttonOr if you're developing this repository in a Go workspace, add the local module path:
go work use ./uiGenerate templ files
Run the templ code generator after any .templ file change.
Generate all _templ.go files from .templ sources:
templ generateOr watch for changes during development:
templ generate --watchBuild & run
Standard Go build commands work as expected.
Run for development
go run main.goBuild a production binary
go build -o ./bin/app .Generate the static docs site
go run ./cmd/generate --output ./bin/siteRun 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>
}
}
}