Build faster with Premium Chakra UI Components 💎

Learn more
Skip to Content
DocsPlaygroundGuidesBlog
Sponsor

Clipboard

Used to copy text to the clipboard

SourceStorybookRecipeArk

Usage

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

Examples

Button

Use the Clipboard.Trigger component to create a copy button.

Input

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

Timeout

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

Here's an example that combines the Clipboard.Trigger and Clipboard.ValueText components to create a link appearance.

https://chakra-ui.com

Store

Alternatively, you can use the useClipboard hook to create a custom component.

Props

Root

PropDefaultType
timeout '3000'
number

The timeout for the copy operation

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
ids
Partial<{ root: string; input: string; label: string }>

The ids of the elements in the clipboard. Useful for composition.

onStatusChange
(details: CopyStatusDetails) => void

The function to be called when the value is copied to the clipboard

value
string

The value to be copied to the clipboard

Previous

Checkbox

Next

Close Button