useClipboard ​
Hook that manages a copy to clipboard
browser
test coverage
Last changed: last month
TIP
This hook uses navigator.clipboard browser api to provide enhanced functionality. Make sure to check for compatibility with different browsers when using this api
Installation ​
Library
CLI
Manual
typescript
import { useClipboard } from '@siberiacancode/reactuse';
Usage ​
typescript
const { value, copy } = useClipboard();
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
params.enabled? | boolean | false | Whether the copy to clipboard is enabled |
Returns
UseCopyToClipboardReturn
Type declaration ​
typescript
export interface UseCopyToClipboardReturn {
/** The copied value */
value: string | null;
/** Function to copy to clipboard */
copy: (value: string) => Promise<void>;
}
export interface UseCopyToClipboardParams {
/** Whether the copy to clipboard is enabled */
enabled: boolean;
}
Source ​
Source • DemoContributors ​
D
N