// copy text on button click in react
const [textArea, setTextArea] = useState("THis is text")
const copyText = () => {
navigator.clipboard.writeText(textArea);
}
onClick={() => {navigator.clipboard.writeText(this.state.textToCopy)}}
<button
onClick={() => navigator.clipboard.writeText('Copy this text to clipboard')}
>
Copy
</button>
<button
onClick={() => navigator.clipboard.writeText('Copy this text to clipboard')}
>
Copy
</button>
<buttononClick={() => navigator.clipboard.writeText("Copy this text to clipboard")}>
Copy
</button>
import {CopyField} from '@eisberg-labs/mui-copy-field';
<CopyField
label="Click on copy Button"
value={"Enter text"}
onCopySuccess={console.log}
onCopyError={console.log}
copyTooltip={"Some copy tooltip. Default is Copy"}
/>