-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Motivation
When it comes to interacting with the clipboard, multiple options are available. The Clipboard API is not yet widely supported by browsers.
A compatible solution should be available out of the box:
- Try using the new Clipboard API by default
- Fallback to
document.execCommand()if necessary
Basic example
function Example() {
const { copy, cut, paste } = useClipboard();
const [value, setValue] = useState('foo');
return (
<>
<input value={value} onChange={(e) => setValue(e.target.value)} />
<button type="button" onClick={() => copy(value)}>Copy</button>
</>
);
}Details
Lack of permissions (e.g. for pasting) should be handled gracefully with opt-in support for error callbacks.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request