Leptos-Use Guide

use_window_focus

Reactively track window focus with window.onfocus and window.onblur events.

Demo

Usage

use leptos::prelude::*;
use leptos_use::use_window_focus;

#[component]
fn Demo() -> impl IntoView {
let focused = use_window_focus();

view! { }
}

Server-Side Rendering

On the server this returns a Signal that is always true.

Feature

This function is only available if the crate feature use_window_focus is enabled

Source

SourceDemoDocs