Fidely UI v1 beta is now available!. 🚀

Clipboard

A component to copy text to the clipboard

Usage

import { Clipboard } from '@fidely-ui/react'
<Clipboard.Root>
  <Clipboard.Trigger>
    <Clipboard.CopyText />
    <Clipboard.Indicator />
  </Clipboard.Trigger>
  <Clipboard.Input />
</Clipboard.Root>

Examples

Input

Use the Clipboard.Input component to create a copy input.

Timer

Use the timeout prop to change the duration of the copy message.

Store

You can use the useClipboard hook to create a custom clipboard component.

With Status Text

You can use the Clipboard.Status to show a copy text.

Root Provider

Use the useClipboard hook together with the Clipboard.RootProvider component to manually control the clipboard’s state and behavior.

This setup gives you maximum flexibility — you can:

  • Access clipboard state programmatically (e.g. clipboard.copied).

  • Trigger copying from anywhere using clipboard.copy().

  • Share the same clipboard store across multiple components.

When using Clipboard.RootProvider, you don’t need to use Clipboard.Root.

Props

Clipboard.Root

PropTypeDefaultDescription
timeoutnumber3000msDuration (in milliseconds) for how long the copied indicator or status text is displayed.
onCopy(value: string) => void-Callback fired after text is successfully copied.
valuestring-The text value to be copied. If not provided, it’s taken from the Clipboard.Input.

Clipboard.Trigger

PropTypeDefaultDescription
asChildbooleanfalsePasses the trigger props to a custom child component instead of rendering a default element.

Clipboard.Input

PropTypeDefaultDescription
readOnlybooleantrueMakes the input field read-only (recommended).
asChildbooleanfalsePasses the custom child component instead of rendering a default element.

useClipboard Hook

PropertyTypeDescription
copiedbooleanWhether the text has been successfully copied.
valuestringThe current value managed by the clipboard store.
copy(value?: string) => voidFunction to trigger the copy action manually.
setValue(value: string) => voidUpdates the clipboard value.

On this page