Copy button
A Button that copies a value. Its icon rolls to a tick and its label to “Copied”, a screen reader hears it, and it goes back after two seconds.
Examples
Default
Give it the value and a label. Its icon rolls to a tick and the label to “Copied”, then both go back.
Icon only
An icon size takes an aria-label, which its tooltip shows; after a press the tooltip says how the copy went.
In a field
Put it in an InputGroupAddon, at the size of the field’s buttons.
npm install @kino/sdkCopy codeIn a code block
A function for value is read at the press, so it copies the text on the page as it is then.
Async value
A function may return a promise, for text it fetches at the press. A wait past 200ms shows the spinner.
Render
Pass another button with render, such as a ToolbarButton, and it copies the same way.
Installation
npx shadcn@latest add https://kinoui.com/r/copy-button.json- Files
lib/refs.tslib/reduce-motion.tslib/resize.tslib/swap.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxlib/popup.tslib/glide.tsxcomponents/kino/tooltip.tsxlib/announce.tsxcomponents/kino/copy-button.tsx- Packages
@base-ui/reactclass-variance-authority- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
API reference
Props
Data attributes
Accessibility
- A polite status region beside the button says “Copied” or “Couldn’t copy”, and says it again on the next press.
- An icon-only button keeps its name, such as “Copy API key”, so it reads the same each time; its tooltip shows the name to everyone else.
- Focus stays on the button, and while a fetched value is on its way the button is busy and takes no second press.
- A failure shows an alert icon and words, not a colour alone.
- Where the browser refuses the Clipboard API, as on plain http or in an iframe without
clipboard-write, it copies through a hidden selection instead, and puts focus back.