Skip to content
OpenPerf
Esc
↑↓navigate↵open⌘Jpreview
On this page

useCopy

Copies text to the clipboard and confirms it with a toast.

const copy = useCopy();

copy(span.spanId, { title: t`Span ID copied`, description: span.spanId });
  • Use it for copy buttons on IDs, URLs and snippets.
  • Needs a Toast.Provider above it; the confirmation goes through toastManager.
  • The title says what was copied. The description repeats a short value, or says what to do with a long one (“Paste it to share this trace.”).

API

PropType
textstring

First argument. The text to copy.

Typestring
titlestring

On the second argument. Toast title.

Typestring
descriptionstring

On the second argument. Toast description.

Typestring

useCopy() returns copy(text, { title, description }). Built on Toast.

Was this page helpful?