Skip to content
Nana UI

Copy Button

A button that copies text to the clipboard and shows a brief “copied” confirmation. Copy a literal value, or read the text from another element via the from selector. Renders icon-only by default; set show-label to display the swapping Copy → Copied text.

Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/copy-button";
<nana-copy-button value="npm install @nana-tec/ui-components"></nana-copy-button>
PropertyTypeDefaultDescription
valuestring''Literal text to copy (used when from is unset or resolves to nothing)
fromstring | undefinedCSS selector for an element to read the copy text from (value or text)
labelstring'Copy'Label shown before copying (and the accessible name when icon-only)
copiedLabelstring'Copied'Label shown after a successful copy
showLabelbooleanfalseShow the visible text label alongside the icon
variant'default' | 'ghost' | 'outlined''default'Visual style
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Size
disabledbooleanfalseDisable the button
copyIconIconName'content_copy'Icon shown in the idle state
copiedIconIconName'done_all'Icon shown in the copied state
feedbackDurationnumber2000How long the copied state persists, in milliseconds
EventTypeDescription
nana-copyCustomEventFired after a successful copy (detail.value)
nana-errorCustomEventFired when the copy fails (detail.error)
VariableDefaultDescription
--nana-copy-button-radiusCorner radius
--nana-copy-button-colorIcon / text colour
PartDescription
buttonThe underlying button
iconThe copy / success icon
  • Keyboard accessible
  • Screen-reader labels
  • Focus-visible states
  • ARIA roles and states
  • WCAG 2.2 AA contrast
Explore Copy Button interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook