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.Providerabove it; the confirmation goes throughtoastManager. - 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.
Type
stringtitlestring
On the second argument. Toast title.
Type
stringdescriptionstring
On the second argument. Toast description.
Type
stringuseCopy() returns copy(text, { title, description }). Built on Toast.