Copy button
A button that copies a link and shows that it worked.
A button that copies a link and shows that it worked.
npm install @mantine/core @mantine/hooks @tabler/icons-react
First time with Mantine UI? Set it up once.
/**
* Component from Mantine UI, https://ui.mantine.dev
* MIT License, Copyright (c) 2022 Vitaly Rtischev. Full text: https://github.com/mantinedev/ui.mantine.dev/blob/master/LICENCE
* Changed for Tastebud: it copies a sample link.
*/
import { IconCheck, IconCopy } from '@tabler/icons-react';
import { Button, Tooltip } from '@mantine/core';
import { useClipboard } from '@mantine/hooks';
export function ButtonCopy() {
const clipboard = useClipboard();
return (
<Tooltip
label="Link copied!"
offset={5}
position="bottom"
radius="xl"
transitionProps={{ duration: 100, transition: 'slide-down' }}
opened={clipboard.copied}
>
<Button
variant="light"
rightSection={
clipboard.copied ? (
<IconCheck size={20} stroke={1.5} />
) : (
<IconCopy size={20} stroke={1.5} />
)
}
radius="xl"
size="md"
pr={14}
h={48}
styles={{ section: { marginLeft: 22 } }}
onClick={() => clipboard.copy('https://example.com/invite')}
>
Copy link to clipboard
</Button>
</Tooltip>
);
}
Changed for this site: It copies a sample link.