leptos_use

Function use_drop_zone

Source
pub fn use_drop_zone<El, T>(target: El) -> UseDropZoneReturn
where El: Clone + Into<ElementMaybeSignal<T, EventTarget>>, T: Into<EventTarget> + Clone + 'static,
Expand description

Create a zone where files can be dropped.

§Demo

Link to Demo

§Usage

let drop_zone_el = create_node_ref::<Div>();

let on_drop = |event| {
    // called when files are dropped on zone
};

let UseDropZoneReturn {
    is_over_drop_zone,
    ..
} = use_drop_zone_with_options(
    drop_zone_el,
    UseDropZoneOptions::default().on_drop(on_drop)
);

view! {
    <div node_ref=drop_zone_el>
        "Drop files here"
    </div>
}

§Server-Side Rendering

On the server the returned file signal always contains an empty Vec and is_over_drop_zone contains always false