1
0
mirror of https://github.com/axzilla/templui.git synced 2025-02-23 20:23:49 +00:00
templui/pkg/components/themeswitcher.templ
2024-10-13 18:02:09 +02:00

32 lines
576 B
Plaintext

package components
import "github.com/axzilla/goilerplate/pkg/icons"
templ ThemeSwitcher() {
@Button(ButtonProps{
Size: ButtonIcon,
Variant: Ghost,
IconLeft: templ.Component(DynamicThemeIcon()),
Attributes: templ.Attributes{
"@click": "toggleTheme()",
},
})
}
templ DynamicThemeIcon() {
<span x-show="appTheme === 'dark'" class="block">
@LightIcon()
</span>
<span x-show="appTheme === 'light'" class="block">
@DarkIcon()
</span>
}
templ DarkIcon() {
@icons.Moon(icons.IconProps{})
}
templ LightIcon() {
@icons.SunMedium(icons.IconProps{})
}