Function leptos_use::use_favicon

source ·
pub fn use_favicon() -> (Signal<Option<String>>, WriteSignal<Option<String>>)
Expand description

Reactive favicon.

§Demo

Link to Demo

§Usage

let (icon, set_icon) = use_favicon();

set_icon.set(Some("dark.png".to_string())); // change current icon

§Passing a Source Signal

You can pass a Signal to use_favicon_with_options. Change from the source signal will be reflected in your favicon automatically.

let is_dark = use_preferred_dark();

let (icon, _) = use_favicon_with_options(
    UseFaviconOptions::default().new_icon(
        Signal::derive(move || {
            Some((if is_dark.get() { "dark.png" } else { "light.png" }).to_string())
        }),
    )
);

§Server-Side Rendering

On the server only the signals work but no favicon will be changed obviously.