use leptos::*; use leptos_use::docs::demo_or_body; use leptos_use::on_click_outside; #[component] fn Demo(cx: Scope) -> impl IntoView { let (show_modal, set_show_modal) = create_signal(cx, false); let modal_ref = create_node_ref(cx); let _ = on_click_outside(cx, modal_ref, move |_| set_show_modal.set(false)); view! { cx, "Open Modal" "𝖷" "Demo Modal" "Click outside this modal to close it." } } fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); mount_to(demo_or_body(), |cx| { view! { cx, } }) }
"Demo Modal"
"Click outside this modal to close it."