Skip to main content

theme_radio

Function theme_radio 

Source
pub fn theme_radio()
Expand description

Wires up every [name=theme-radios] radio button on the page: checks the one whose value matches the resolved theme (see [prefers_color_scheme]), and attaches a click listener that sets data-theme to the checked control’s value.

Calling this more than once (e.g. a rerun use_effect) is safe: a control that’s already wired up is left alone rather than gaining a duplicate listener.

§Panics

Panics if called outside a browser main-thread context (no window, or no document on it).