UNPKG

@kadoui/react

Version:

Kadoui primitive components for React

12 lines (11 loc) 575 B
"use client"; import { jsx as _jsx } from "react/jsx-runtime"; import { useClipboard } from "@mantine/hooks"; export function Clipboard({ copiedChildren, onClick, children, text, title, "aria-label": ariaLabel, timeout = 3_000, ...props }) { const { copy, copied } = useClipboard({ timeout }); const handleClick = (ev) => { onClick?.(ev); copy(text.trim()); }; return (_jsx("button", { "aria-label": ariaLabel || text, title: title || text, onClick: handleClick, ...props, children: copiedChildren && copied ? copiedChildren : children })); }