Basic

import CopyButton from '@davaux/ui/CopyButton'

<CopyButton value="Hello, world!" />

Custom labels

<CopyButton
  value="npm install @davaux/ui"
  label="Copy install command"
  copiedLabel="Copied!"
/>

Short timeout

<CopyButton value="quick" timeout={500} copiedLabel="✓" />

Multiple copy buttons

npm install @davaux/ui
pnpm add @davaux/ui
<Group gap="sm" align="center">
  <code>npm install @davaux/ui</code>
  <CopyButton value="npm install @davaux/ui" />
</Group>

Props

PropTypeDefaultDescription
valuestringText written to the clipboard (required)
timeoutnumber2000Milliseconds to show the copied state before resetting
labelstring'Copy'Button label in the default (not-yet-copied) state
copiedLabelstring'Copied'Button label shown after a successful copy
classstringAdditional CSS class names on the button