Clipboard
Copies text to the clipboard and shows that it was copied.
Usage
import { Clipboard } from '@leverui/components';
<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.
Link Appearance
Here's an example that combines the Clipboard.Trigger and Clipboard.ValueText components to create a link appearance.
https://leverui.com
Store
Alternatively, you can use the useClipboard hook to create a custom component.
Props
Root
| Prop | Default | Type | Description |
|---|---|---|---|
timeout | 3000 | number | Time the copied state lasts, in milliseconds. |
asChild | — | Solid render function | Render your own element with the clipboard's props. |
defaultValue | — | string | Initial text to copy. |
id | — | string | Unique id. |
ids | — | Element ID map | Your own ids for the clipboard's elements. |
onStatusChange | — | (details) => void | Called when the value is copied. |
onValueChange | — | (details) => void | Called when the value changes. |
translations | — | IntlTranslations | Translated text for screen readers. |
value | — | string | Text to copy. Controlled. |
With a signal as value, Clipboard.Input and Clipboard.ValueText update
with it. Give an icon-only trigger an accessible name, such as an aria-label.
Explorer
Click a part name to highlight it in the preview.
Component Anatomy
Hover to highlight, click to select parts