structyl

Copy Button API

View component

The full prop reference for the Copy Button component. Copies text to the clipboard with success feedback.

Import

tsx
import { CopyButton } from '@structyl/styled';

Props

CopyButton

A button component that copies text to clipboard with visual feedback (icon change and reset timer)

PropTypeDefault
value#string

The text to copy to clipboard when button is clicked (required)

resetAfter#number

Duration in milliseconds before the copied state resets back to idle

2000
onCopied#(value: string) => void

Callback fired after successful clipboard copy

variant#'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link' | 'success' | 'warning' | 'contained' | 'outlined' | 'text'

Button style variant

'ghost'
color#'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success' | 'default' | 'inherit'

Button color (used with semantic variants: contained, outlined, text)

size#'default' | 'sm' | 'lg' | 'xl' | 'icon' | 'icon-sm' | 'icon-lg' | 'icon-xl'

Button size

'icon'
asChild#boolean

If true, renders children as the button element (Slot polymorphism)

false
loading#boolean

When true, shows spinner and disables the button

false
loadingText#React.ReactNode

Text shown next to spinner when loading; defaults to children

leftIcon#React.ReactNode

Icon element rendered before button text

rightIcon#React.ReactNode

Icon element rendered after button text

disabled#boolean

Disables the button and prevents interaction

className#string

CSS class names to merge with component styles

children#React.ReactNode

Button content; if not provided defaults to Copy/Check icons based on state

ref#React.Ref<HTMLButtonElement>

Forward ref to underlying button element

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library