Client component

Copy Button

A Button that writes value to the clipboard and confirms with a transient copied state. It is the general-purpose sibling of CodeBlock.CopyTrigger. Every Button prop (variant, size, colorScheme, …) passes straight through.

Import#

import { CopyButton } from "astralis-ui";

Usage#

value is what lands on the clipboard; the label is separate, so a button can say "Copy link" while copying the full URL. After a successful copy the label swaps to copiedLabel for timeout milliseconds, and the button carries a data-copied attribute you can style against. If the browser refuses clipboard access, the label stays put rather than claiming a copy that didn't happen.

Props#

Takes every Button prop except leftIcon, which the copied state owns. The ones that matter most:

PropTypeDefaultDescription
valuestringNoneThe text written to the clipboard. Required.
childrenReactNode"Copy"Label at rest.
copiedLabelReactNode"Copied"Label while the copied state lasts.
timeoutnumber1600How long the copied state lasts, in milliseconds.
variant"solid" | "subtle" | "surface" | "outline" | "text" | "link""solid"Button style, as on Button.
size"xs" | "sm" | "md" | "lg" | "xl""md"Button size, as on Button.
colorSchemeall 15 schemes"brand"Button hue, as on Button.

Accessibility#

The copied state changes the button's label, but it isn't a live region, so a screen reader reports it only when the button is read again. Keep copiedLabel meaningful on its own ("Link copied" rather than "Done").