themetoggle

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 2 Imported by: 0

README

ThemeSwitch

Componente visual para alternar el tema de la aplicación (light / dark / auto).

Características

  • 3 estados: auto (preferencia del OS), dark y light.
  • Persistencia automática en localStorage.
  • Botón flotante fijo en la esquina superior derecha.
  • Diseñado para pruebas de desarrollo de componentes en diferentes temas.

Uso

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Theme

type Theme string

Theme representa el estado de tema del componente. ThemeAuto ("") = sin atributo data-theme → OS preference via @media. Los valores "dark" y "light" se escriben literalmente en data-theme.

const (
	ThemeAuto  Theme = "" // no data-theme attribute → OS preference
	ThemeDark  Theme = "dark"
	ThemeLight Theme = "light"
)

type ThemeToggle

type ThemeToggle struct {
	Element
}

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) IconSvg

func (t *ThemeToggle) IconSvg() map[string]string

func (*ThemeToggle) OnMount

func (t *ThemeToggle) OnMount()

En SSR no hay localStorage ni clicks. Stubs no-op para compilación correcta.

func (*ThemeToggle) Render

func (t *ThemeToggle) Render() *Element

func (*ThemeToggle) RenderCSS

func (t *ThemeToggle) RenderCSS() *Stylesheet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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