templette is a Go front-end toolkit built on top of templ. It focuses on reusable server-rendered HTML building blocks: typed HTML attributes, dynamic HTML element helpers, page wrappers, reusable component packages, and higher-level wrappers for composing application UI.
- Reusable HTML components in
components/ - Dynamic tag rendering in
element/ - Page-level layout helpers in
page/ - Typed attribute helpers in
props/ - Reusable higher-level wrappers in
wrappers/
The goal is to let you build .templ templates from small, composable primitives instead of writing raw HTML everywhere.
A collection of reusable HTML component packages. Each subpackage focuses on a specific HTML concern or component family, such as:
buttondivdropdownfieldsetforminputlabellayoutmediameterprogresssemantictabletexttextarea
These packages are meant to be imported and used as ready-made building blocks inside your templ components.
A low-level HTML element package for dynamic tag creation.
It exposes:
Tag— a typed list of supported HTML tagsElement(t Tag, ...props.AttrsProvider)— renders a normal HTML elementVoidElement(t Tag, ...props.AttrsProvider)— renders a self-closing / void element
This package is useful when you want one helper that can render many tags at runtime while still staying inside the templ component model.
A typed attribute layer around templ.Attributes.
It provides:
Attrs— a wrapper aroundtempl.AttributesWith(key, value)— set any attributeWithID(id)— set theidWithClass(class)— append or set CSS classesWithStyle(style)— append or set inline stylesMerge(other)— merge attribute mapsAsTemplAttrs()— convert totempl.AttributesAttrsProvider— an interface for anything that can produce templ attributes
This package is the foundation for passing HTML attributes through the rest of the toolkit.
Page-level wrappers for full HTML documents.
The package centers around:
Props— a struct that groups:HTMLHeadBody
Use this package when you need a full page shell rather than a single component.
Reusable high-level wrappers built on top of the lower-level component packages.
These wrappers are intended for consistent UI composition and shared styling. The package-level props are mutable, which makes global customization easy, but they are not thread-safe to change at runtime.
A typical flow looks like this:
- Build attributes with
props.Attrsor wrappers around the struct. - Render a tag with
element.Elementorelement.VoidElement - Compose those tags into reusable components in
components/ - Wrap whole pages with
page/ - Apply shared styles and patterns with
wrappers/
attrs := props.Attrs{}.
WithID("hero").
WithClass("container").
With("data-role", "hero")
card := element.Element(element.Div, attrs)
logo := element.VoidElement(element.Img, props.Attrs{}.
With("src", "/logo.svg").
With("alt", "Logo"))import (
"github.com/Deirror/templette/components/div"
"github.com/Deirror/templette/components/media/img"
)
attrs := div.Props{
Attrs: props.Attrs{}.
WithID("hero").
WithClass("container"),
Data: data.Props{}.With("role", "hero")
}
card := div.Div(attrs) // uses element.Element templ funcInside .templ files, these helpers can be combined to build structured HTML without dropping down to raw markup for every element.
- Go
1.25.4 templv0.3.960
- The generated files in this repository are produced by
templand should not be edited by hand. templetteis designed for server-rendered HTML and templ-based composition.- The project is MIT licensed.
Issues and pull requests are welcome.