Custom functionality for copy button in CodeBlock component #2689
-
Hello team, I have a question regarding the CodeBlock component . The component includes its own copy button. I couldn't find anything about it in the docs. I guess either hiding or customizing would be good for us. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @rmatuszczakp, Thanks for posting this! Would a const myCodeBlock = () => {
const myCode = `const id = XXXX`;
return (
<CodeBlock
code={myCode}
language='javascript'
copyTextFormatter={(myCode) => {
const formattedCode = myCode;
// do something to the string
return formattedCode;
}}
/>
)
} |
Beta Was this translation helpful? Give feedback.
Hi @rmatuszczakp,
Thanks for posting this! Would a
copyTextFormatter
prop work for your use case? It would work like this: