Skip to main content
v1.9.0

templ-components

Server-rendered UI components for Go. Built with templ, HTMX, and Tailwind CSS v4.

Documentation
116
Components
102
Icons
11
Packages

# Layout Primitives

Container (width variants)

Centered max-width wrapper with responsive padding. Replaces the repeated max-w-Nxl mx-auto px-4 sm:px-6 lg:px-8 snippet.

SM (max-w-3xl)
MD (max-w-5xl)
LG (max-w-7xl, default)
Prose (max-w-prose)

Stack (vertical rhythm)

Typed gap enum replaces repeated space-y-N strings. 1D vertical (flex, not grid).

Stack item 1

Stack item 2

Stack item 3 — each child gets consistent spacing

Split (content + aside)

2-column grid for article+sidebar / detail+metadata. RTL-aware logical positioning (Start/End). Stacks below md.

Main content (2/3)

Article body, detail view, or primary content lives here.

AppShell (sidebar + header + main)

The #1 admin dashboard pattern. Uses minmax(0,1fr) to prevent grid blowout from wide tables. Sidebar hidden on mobile (use MobileNav slot for drawer).

Header (sticky-capable)

Main content area

Wide tables, grids, and content live here. minmax(0,1fr) prevents this column from blowing out the viewport.

Stat card

Stat card

Footer (multi-column grid)

Backward-compatible extension: Columns empty = legacy single-row. Non-empty = responsive multi-column grid with optional brand + BottomBar.

# Cards

Standard Card

With title, subtitle, and body

This is a standard card with header and content.

SimpleCard — no header, just content.

Go
display.Card(display.CardProps{Title: "Users", Subtitle: "Manage your team"}) {
	<p>Card content</p>
}

# Stat Cards

Users
1,204
Increased by 12%
Revenue
$45.2K
Decreased by -3%
Uptime
99.9%
Active
42

# Badges

DefaultSuccessErrorWarningInfoPill Dot
healthy degraded down pending active

# Buttons

External Link
Go
display.Button(display.ButtonProps{Text: "Save", Variant: display.ButtonPrimary})

# Avatars

John Doe
Alice Brown
Charlie Day

# Modal (native dialog)

Demo Modal

This modal uses the native <dialog> element with showModal(). Press Escape or click backdrop to close.

Go
@display.Modal(display.ModalProps{Title: "Confirm", Size: display.ModalSizeMD}) {
	<p>Are you sure?</p>
}

# Drawer (native dialog)

Demo Drawer

Drawer slides in from the side using native <dialog>.

# Dropdown

# Tooltip

# Popover

# Accordion (native details)

What is templ-components?
How do I install it?
Is it production-ready?

# Tabs

# Tabs (Pills variant)

# Table

Name ↑EmailRole
Alice Smithalice@example.comAdmin
Bob Jonesbob@example.comUser
Go
display.Table(display.TableProps{
	Headers: []string{"Name", "Email", "Role"},
	Rows: []display.TableRow{
		display.SimpleTableRow("Alice", "alice@example.com", "Admin"),
	},
	Striped: true,
	Hover:   true,
})

# Table in Card (Flush + Compact)

Recent Users

NameEmailStatus
Alice Smithalice@example.comActive
Bob Jonesbob@example.comInvited

# DataTable (sort + pagination)

Name ↑Email
Alicealice@example.com
Bobbob@example.com

# PageHeader

User Settings

Manage your account preferences and security options

# SectionHeading + DateRange

Experience

SectionHeading — configurable h1–h6 level, alignment, subtitle

Go
@display.DateRange(display.DateRangeProps{
	Start: &start, // End nil renders "Present"
	Layout: display.DateFormatJan2_2006,
})

# Definition List

User ID
usr_01JXEXAMPLE
Email
admin@example.com
Plan
Enterprise

# Definition Grid

CPU
42%
Memory
8.2 GB
Disk
156 GB
Uptime
99.9%
Requests
1.2K/s
Latency
12ms

# Grid + Container Query Grid

Normal grid
42
Responsive
12ms
To viewport
99.9%

Container-responsive (resize this box):

Requests/s
42
Latency
12ms
Uptime
99.9%
Go
display.Grid(display.GridProps{Cols: display.GridCols3, Gap: display.GridGapLG}) {
	for _, u := range users {
		@display.Card(display.CardProps{Title: u.Name}) { <p>{ u.Email }</p> }
	}
}

# Fluid Typography (container query units)

Container-aware metric

Revenue scales with this card's width:

$4.2M

Heading in a narrow container

Text shrinks smoothly as the container narrows via cqi units.

# Empty States

No users found

Try adjusting your search or filters.

No data to display.

# CopyButton

# RelativeTime

2 hours ago: 1 day ago:

# CountBadge

# ListNote

Showing 50 of 127. Narrow your search to see more.

# Image

Demo Rounded

# HoverCard

# ContextMenu

Right-click the area below:

Right-click here for context menu
Slide 1
Slide 2
Slide 3

# Sparklines & Bar Charts

Message Trend

+47%

Top Channels

# SVG Charts (Line, Pie, Area)

Revenue Trend

10 20 30 40 50 60 70 80 MonTueWedThuFriSatSun

Revenue vs Expenses

Active Users

Traffic Sources

Storage Usage

# Collapsible Sections

Advanced Settings

These settings are open by default. Users can collapse this section to focus on the overview.

Debug Information

Version: v1.9.0 Build: 2026-08-29T08:14:45Z

# Heatmap

Weekly Activity Heatmap

# Alerts

Go
feedback.Alert(feedback.AlertProps{Title: "Saved", Message: "Changes saved.", Type: feedback.FeedbackSuccess})

# Toast (auto-generated ID, auto-dismiss)

Toasts render into ToastContainer. Each auto-dismisses after 5s.

Settings saved!
Error
Upload failed.
Storage almost full.
New version available.
Go
feedback.Toast(feedback.ToastProps{Message: "Saved!", Type: feedback.FeedbackSuccess, Duration: 5000})

# Inline Feedback

Username is available
Saving...

# Spinners

# Progress Bars

Uploading... 45%
Complete 100%
Processing...

# CircularProgress

72%

md + label

sm

lg + custom color

# LoadingOverlay

Full-screen overlay for page transitions — pinned to this frame for the demo via a Class override:

# Step Indicator

# Skeletons

# Skeleton Card Grid

# Form Controls

Tell us about yourself.

Select a plan
50
Rate quality
go templ
Go
forms.Input(forms.InputProps{Name: "email", Type: forms.InputEmail, Label: "Email"})

# Calendar

August 2026

Su
Mo
Tu
We
Th
Fr
Sa

# ValidationSummary

# Inline Form (Filter Bar)

Filter results appear here (change the Sort dropdown — it auto-submits via HTMX).

Click to fetch the next batch from /api/items — the button replaces itself with the response:

Item 001

Loaded from the server via HTMX.

Item 002

Loaded from the server via HTMX.

hx-trigger="revealed" — fires as soon as the button scrolls into view:

Item 003

Loaded from the server via HTMX.

Item 004

Loaded from the server via HTMX.

You've reached the end

© 2026 templ-components v1.9.0. All rights reserved.

# HTMX LoadingIndicator

Global HTMX loading overlay (shows during any htmx request — try any button below):

Loading…

# HTMX InlineLoadingOverlay

Per-target loading indicator (shown via hx-indicator):

Loading…

# HTMX LoadingButton

Click — the button swaps to its loading state during the request:

# HTMX ConfirmDelete

Deletes the item below via HTMX after a confirmation dialog:

item-123

Delete me — the row is replaced by the server response.

# HTMX CSRFToken

Renders a hidden CSRF input field:

# HTMX SwapOOB

Out-of-band swap element (processed by HTMX after a response):

target: current value

# HTMX GlobalErrorHandling

Wires up htmx:responseError and htmx:beforeOnError events:

# HTMX ViewTransitions

Enables native View Transitions on HTMX swaps — pages cross-fade instead of hard-cutting, with graceful degradation in browsers without support.

Go
htmx.ViewTransitions(htmx.ViewTransitionsProps{Global: true, Nonce: nonce})

# HTMX PolledRegion

Auto-refreshing region polling /api/demo-stats every 5s (stops after 3 ticks):

Requests served: 48210

Updated 08:14:45 UTC

auto-refreshing

# Datastar SDKScript

Injects the Datastar runtime as an ES module. Load once per page:

# Datastar LiveRegion

SSE-powered region that auto-connects on page load and self-heals across server restarts (retry: 'always'). The server pushes datastar-patch-elements events to patch the content in real-time (no polling):

Waiting for SSE stream...

# Datastar Indicator

Shows/hides based on a Datastar indicator signal. Place data-indicator:fetching on any element that triggers a backend action:

# Datastar Action Expressions

Typed helpers for building Datastar action expressions:

datastar actions
datastar.Get("/api/search")       // @get('/api/search')
datastar.Post("/api/save")      // @post('/api/save')
datastar.Delete("/api/items/1") // @delete('/api/items/1')

# Datastar SSE Error Handling

Global listener for Datastar stream failures (datastar-fetch events with type error or retries-failed) that surfaces them as accessible toasts — the Datastar counterpart to HTMX GlobalErrorHandling:

Go
@feedback.ToastContainer("")
@datastar.SSEErrorHandling(datastar.DefaultSSEErrorHandlingConfig())

HTMX vs Datastar

Both work side-by-side. HTMX uses hx-* attributes for hypermedia exchanges. Datastar uses data-* attributes for SSE streaming and reactive signals.

Use HTMX for request-response (forms, navigation, CRUD). Use Datastar for real-time push (dashboards, live feeds, collaborative editing).

# ECharts SDK + Chart (opt-in module)

charts/echarts is a separate opt-in module: it wraps go-echarts RenderSnippet() output in a CSP-safe container and bridges dark mode — toggle the theme and watch the chart re-theme.

Go
import echarts "github.com/larsartmann/templ-components/charts/echarts"

@echarts.SDKScript(echarts.DefaultSDKScriptProps())
@echarts.EChart(echarts.EChartsProps{
	Element: snippet.Element, // from go-echarts RenderSnippet()
	Script:  snippet.Script,
	Nonce:   nonce,
})

# NotFound404

Page not found

The page you're looking for doesn't exist or has been moved.

# ErrorPage

rejection

The resource was not found

Suggested fix: Check the URL or return to the homepage.

# ErrorAlert (by family)

# ErrorDetail (with context + cause chain)

# All Icons (102)

Search the icon library by name. Click an icon to copy its Go constant name.

# Recipes & Full Pages