layout

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 4 Imported by: 5

Documentation

Overview

templ: version: v0.3.1036

Package layout provides page-level layout components including base HTML shell, containers, and structural templates.

Package layout pins the HTMX CDN scripts and their Sub-Resource Integrity hashes.

templ: version: v0.3.1036

Index

Constants

View Source
const (
	// DefaultThemeColor is the default light-mode theme color (indigo-600)
	DefaultThemeColor = "#4f46e5"
	// DefaultDarkThemeColor is the default dark-mode theme color (indigo-950)
	DefaultDarkThemeColor = "#1e1b4b"
)

Variables

This section is empty.

Functions

func Base

func Base(props PageProps) templ.Component

Base renders a complete HTML5 base layout with HTMX, theme support, and meta tags Use with children... to inject page content into the body

@layout.Base(props) {
  <h1>My Page</h1>
}

func Minimal

func Minimal(props MinimalProps) templ.Component

Minimal renders a minimal HTML5 document without HTMX or external dependencies Useful for static pages, emails, or PDF generation

@layout.Minimal(layout.MinimalProps{Title: "My Title"}) {
  <h1>Hello</h1>
}

func ThemeScript

func ThemeScript(nonce string) templ.Component

ThemeScript renders the inline script that sets the dark mode class before paint Include this in your base template head to prevent FOUC

func ThemeToggle

func ThemeToggle(ariaLabel string, nonce string) templ.Component

ThemeToggle renders a theme toggle button with sun/moon icons Requires Tailwind CSS dark: variants and the ThemeScript in your base layout

@layout.ThemeToggle("Toggle theme")

Types

type MinimalProps

type MinimalProps struct {
	Title  string
	Locale string
}

MinimalProps configures a minimal HTML5 document without HTMX or external dependencies

func DefaultMinimalProps

func DefaultMinimalProps() MinimalProps

DefaultMinimalProps returns sensible defaults for MinimalProps

type PageProps

type PageProps struct {
	Title          string
	Description    string
	Locale         string
	OGImage        string
	ThemeColor     string
	DarkThemeColor string
	CSSPath        string
	Favicon        string
	HTMXVersion    string
	HTMXUseSRI     bool
	BodyClass      string
	Nonce          string
	HeadContent    templ.Component
	Footer         templ.Component
	// SecurityHeaders controls whether security meta tags are included
	SecurityHeaders bool
}

PageProps configures the base page layout

func DefaultPageProps

func DefaultPageProps() PageProps

DefaultPageProps returns sensible defaults for PageProps

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL