themecontroller

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

templ: version: v0.3.977

Index

Constants

View Source
const SetThemePath = "/theme"

SetThemePath is the route path for the theme persistence endpoint.

Variables

This section is empty.

Functions

func ButtonGroup

func ButtonGroup(props ButtonGroupProps) templ.Component

func IconToggle added in v0.0.31

func IconToggle(props IconToggleProps) templ.Component

func RadioGroup

func RadioGroup(props RadioGroupProps) templ.Component

func Route added in v0.0.31

func Route(secure bool) func(chi.Router)

Route returns a RouteOption that registers the theme persistence handler. The secure flag controls the Secure attribute on the theme cookie.

func SetThemeHandler added in v0.0.7

func SetThemeHandler(secure bool) http.HandlerFunc

SetThemeHandler returns an HTTP handler that persists the selected theme to a cookie. It reads the theme from Datastar signals and sets the webx_theme cookie.

func Toggle

func Toggle(props ToggleProps) templ.Component

Types

type ButtonGroupProps

type ButtonGroupProps struct {
	ID         string
	Class      string
	Attributes templ.Attributes
	Default    string        // initially selected theme
	Themes     []ThemeOption // available themes
}

ButtonGroupProps configures a button-strip theme selector.

type IconToggleProps added in v0.0.31

type IconToggleProps struct {
	ID         string
	Class      string
	Attributes templ.Attributes
	Dark       string // dark theme name (e.g. "dark")
	Light      string // light theme name (e.g. "silk", "light")
	Size       int    // icon size in px (default 20)
}

IconToggleProps configures an icon-based toggle between a light and dark theme. Displays a sun icon in dark mode (click to go light) and a moon icon in light mode (click to go dark).

type RadioGroupProps

type RadioGroupProps struct {
	ID         string
	Class      string
	Attributes templ.Attributes
	Default    string        // initially selected theme
	Themes     []ThemeOption // available themes
}

RadioGroupProps configures radio buttons for selecting from multiple themes.

type ThemeOption

type ThemeOption struct {
	Value string
	Label string
}

ThemeOption represents a selectable theme.

type ThemeSignals

type ThemeSignals struct {
	Theme string `json:"theme"`
}

ThemeSignals holds the reactive theme state.

type ToggleProps

type ToggleProps struct {
	ID         string
	Class      string
	Attributes templ.Attributes
	Theme      string // theme to apply when toggled on
	Default    string // theme when toggled off (defaults to "default")
}

ToggleProps configures a toggle switch between two themes.

Jump to

Keyboard shortcuts

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