Skip to main content

Module theme

Module theme 

Source
Expand description

Changing the theme while the application runs, and the palettes that come with it.

LaunchBuilder::with_theme settles the theme once, before anything is drawn, and a const palette rides on it as a &'static reference. An application that lets the reader pick a design system, a scheme or a brand colour at run time needs to send a new SetTheme, and a palette built at run time has no 'static home of its own.

ThemeHandle is that path, and the Dioxus adapter’s use_theme hook hands one out. Setting a theme queues it and it rides out on the batch the current call produces, the way a message does: one record, applied by the Renderer to the whole tree. A palette handed over by value is owned here, so application code never leaks anything to satisfy the lifetime.

Structs§

SystemColorSchemeSubscription
A registration for changes of the system appearance, ended by dropping it.
ThemeHandle
A handle on the running theme. Copy, so it can move into any number of handlers.

Functions§

current_theme
The theme the application is running with: what it launched with, or what it last set.
own_palette
A palette made at run time, given a home that lives as long as the program.
resolved_color_scheme
The scheme the theme is drawn in: the theme’s own choice when it names one, and the system’s when it follows the system. None only while it follows a system that has not been reported yet.
set_theme
Replaces the whole theme. The Renderer receives it in the batch this call produces.
subscribe_system_color_scheme
Registers notify to be called each time the system appearance changes. A runtime’s hook for the scheme holds one for as long as the reader it wakes is alive.
system_color_scheme
Whether the system appearance is light or dark, as the Renderer last reported it, or None before its first report.