@mantine/code-highlight
Version:
Code highlight with Mantine theme
27 lines (24 loc) • 788 B
JavaScript
'use client';
import { jsx } from 'react/jsx-runtime';
import { useClipboard } from '@mantine/hooks';
import { CodeHighlightControl } from '../CodeHighlightControl/CodeHighlightControl.mjs';
import { CopyIcon } from './CopyIcon.mjs';
function CopyCodeButton({
code,
copyLabel = "Copy",
copiedLabel = "Copied"
}) {
const clipboard = useClipboard();
return /* @__PURE__ */ jsx(
CodeHighlightControl,
{
onClick: () => clipboard.copy(code.trim()),
variant: "none",
tooltipLabel: clipboard.copied ? copiedLabel : copyLabel,
children: /* @__PURE__ */ jsx(CopyIcon, { copied: clipboard.copied })
}
);
}
CopyCodeButton.displayName = "@mantine/code-highlight/CopyCodeButton";
export { CopyCodeButton };
//# sourceMappingURL=CopyCodeButton.mjs.map