doum
2025-09-26 9057e04efad1b7d61c77a72e5c37a504d0aee935
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/// <reference lib="dom"/>
 
export interface Options {
    /**
    Specify a DOM element where the temporary, behind-the-scenes `textarea` should be appended, in cases where you need to stay within a focus trap, like in a modal.
 
    @default document.body
 
    @example
    ```
    import copy from 'copy-text-to-clipboard';
 
    const modalWithFocusTrap = document.getElementById('modal');
 
    button.addEventListener('click', () => {
        copy('🦄🌈', {
            target: modalWithFocusTrap
        });
    });
    ```
    */
    readonly target?: HTMLElement;
}
 
/**
Copy text to the clipboard.
 
Must be called in response to a user gesture event, like `click` or `keyup`.
 
@param text - The text to copy to clipboard.
@returns Whether it succeeded to copy the text.
 
@example
```
import copy from 'copy-text-to-clipboard';
 
button.addEventListener('click', () => {
    copy('🦄🌈');
});
```
*/
export default function copyTextToClipboard(text: string, options?: Options): boolean;