Files
impersonator/components/Body/CopyToClipboard.tsx

26 lines
530 B
TypeScript
Raw Permalink Normal View History

import { Button, useToast } from "@chakra-ui/react";
2023-06-10 17:00:21 +05:30
import { CopyIcon } from "@chakra-ui/icons";
const CopyToClipboard = ({ txt }: { txt: string }) => {
const toast = useToast();
return (
<Button
onClick={() => {
navigator.clipboard.writeText(txt);
toast({
title: "Copied to clipboard",
status: "success",
isClosable: true,
duration: 1000,
});
}}
size="sm"
>
<CopyIcon />
</Button>
);
};
2023-06-10 17:00:21 +05:30
export default CopyToClipboard;