themetoggle

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 3 Imported by: 0

README

ThemeToggle

Signal-driven component to toggle the application theme (light / dark / auto).

Features

  • 3 states: auto (OS preference), dark, and light.
  • Automatic persistence in localStorage via Init.
  • Fixed floating button.
  • Signal-driven: updates icon and labels surgically without re-rendering the whole button.

Usage

import (
	"github.com/tinywasm/components/themetoggle"
	"github.com/tinywasm/dom"
)

func main() {
	ts := &themetoggle.ThemeToggle{}
	dom.Append("body", ts)
	select {}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ThemeToggle

type ThemeToggle struct {
	Element
	// contains filtered or unexported fields
}

ThemeToggle es un botón flotante que cicla entre los 3 modos de tema. Restaura automáticamente el tema guardado en localStorage al montarse.

ts := &themetoggle.ThemeToggle{}
Append("body", ts)

func (*ThemeToggle) Init added in v0.1.7

func (t *ThemeToggle) Init(_ Ctx)

func (*ThemeToggle) Render

func (t *ThemeToggle) Render() *Element

func (*ThemeToggle) RenderCSS

func (t *ThemeToggle) RenderCSS() *Stylesheet

type TsTheme added in v0.1.7

type TsTheme string

TsTheme representa el estado de tema del componente.

const (
	TsThemeAuto  TsTheme = ""
	TsThemeDark  TsTheme = "dark"
	TsThemeLight TsTheme = "light"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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