Skip to main content

theme_select

Function theme_select 

Source
pub fn theme_select()
Expand description

Wires up every [name=theme-select] <select> on the page: sets its value to the resolved theme (see [prefers_color_scheme]), and attaches a change listener that sets data-theme to the newly selected 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).