Your original post wasn’t entirely clear. If you meant to alternate between classes, then that’s more cycling than toggling.
Honestly, I’d simply use the
Setting.addList() API, there’s an example of this very thing there.
That said, you could do something like the following: (untested, written on my phone)
<<removeclass "html" $theme>>
<<set _next to 1 + setup.themes.indexOf($theme)>>
<<if _next is setup.themes.length>><<set _next to 0>><</if>>
<<set $theme to setup.themes[_next]>>
<<addclass "html" $theme>>
That requires you to also set
setup.themes to an array of theme classes and initialize
$theme: (e.g., in
<<set setup.themes to ["black-theme", "white-theme", "beige-theme"]>>
<<set $theme to setup.themes>>
NOTE: The above doesn’t persist the selected theme, as using the
Setting API would. That said, doing so is possible using the