Skip to main content

window_title

Function window_title 

Source
pub fn window_title(f: impl Fn() -> String + 'static)
Expand description

Bind the title of the window this piece is building into to a reactive closure (docs/windows.md). This is how a window comes to be named after what it shows.

The window-level counterpart to a navigation title. It matters more than it looks: the macOS Window menu, the tab bar, Mission Control, the iPad app switcher and the Android recents card all label a window by its title, so two windows that share one title are two windows the user cannot tell apart anywhere the system lists them.

ⓘ
// inside a window's shell, so each window titles itself:
day::window_title(move || match scene.selected.get() {
    Some(id) => scene.name_of(id),
    None => app_title(),
});

Reactive like any binding: the title follows what the closure reads. Which window it targets is resolved once, here, for the same reason toolbar_reactive captures it: the binding re-runs long after this build, when “the window being built” is no longer this one.