// Simplifies copying text/content directly to clipboard
const { copy, copied, history } = useCopyToClipboard({ trackHistory: true });
Perfect for copy-to-clipboard functionality, sharing features, or text utilities requiring clipboard access.
import { useCopyToClipboard } from '@usegrand/react-hokss'; function CopyButton({ text }) { const { copy, copied, error, history } = useCopyToClipboard({ trackHistory: true, maxHistorySize: 5 }); return ( <div> <button onClick={() => copy(text)}> {copied ? 'Copied!' : 'Copy'} </button> {error && <p>Error: {error}</p>} {history.length > 0 && ( <ul> {history.map((item, index) => ( <li key={index}>{item}</li> ))} </ul> )} </div> ); }
Configuration options for clipboard functionality
Whether to track clipboard history (default: false)
Maximum number of items to keep in history (default: 10)
Object containing copy function and state
Function to copy text to clipboard
Boolean indicating if last copy was successful
Error message if copy operation failed
Array of previously copied items
Function to clear clipboard history