Last active
May 29, 2020 18:15
-
-
Save cameronp98/fac7954037246c19a077cf85aadeb0ff to your computer and use it in GitHub Desktop.
Copy Input, requires semantic-ui-react semantic-ui-css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { Button, Input } from 'semantic-ui-react' | |
function CopyInput({ value, label }) { | |
const input = React.createRef() | |
function handleClick() { | |
input.current.select() | |
// input.current.setSelectionRange(0, 99999) | |
document.execCommand('copy') | |
} | |
return ( | |
<Input | |
labelPosition='right' | |
ref={input} | |
readOnly | |
value={value} | |
label={<Button onClick={handleClick} content={label} icon='copy' />} | |
/> | |
) | |
} | |
export default CopyInput |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment