A Rust/UI hook that copies text to clipboard with optional timeout to show copied state.
utils
- Copy Demo
Installation
You can run either of the following commands:
# cargo install ui-cli --forceui add demo_use_copy_clipboardui add use_copy_clipboardUpdate the imports to match your project setup.
Usage
use crate::components::hooks::use_copy_clipboard::use_copy_clipboard;let (copy_to_clipboard, copied) = use_copy_clipboard(Some(2000));
// Copy text to clipboard
copy_to_clipboard("text to copy".to_string());
// Check if recently copied
if copied.get() {
// Show copied state
}