Function leptos_use::use_clipboard
source · pub fn use_clipboard() -> UseClipboardReturn<impl Fn(&str) + Clone>
Expand description
Reactive Clipboard API. Provides the ability to respond to clipboard commands (cut, copy, and paste) as well as to asynchronously read from and write to the system clipboard. Access to the contents of the clipboard is gated behind the Permissions API. Without user permission, reading or altering the clipboard contents is not permitted.
§Demo
§Usage
let UseClipboardReturn { is_supported, text, copied, copy } = use_clipboard();
view! {
<Show
when=move || is_supported.get()
fallback=move || view! { <p>Your browser does not support Clipboard API</p> }
>
<button on:click={
let copy = copy.clone();
move |_| copy("Hello!")
}>
<Show when=move || copied.get() fallback=move || "Copy">
"Copied!"
</Show>
</button>
</Show>
}
§Server-Side Rendering
On the server the returnd text
signal will always be None
and copy
is a no-op.