Copy to Clipboard
Копирование с подтверждением. Бесплатно, MIT · Базовые элементы › Кнопки
Установка
npx valyro-cli@latest add copy-to-clipboard
npx shadcn@latest add https://valyro.xyz/r/copy-to-clipboard.json
npm install valyro-ui
import 'valyro-ui/styles.css';
import { CopyToClipboard } from 'valyro-ui';
Пропсы
| Prop | Type | Default | |
|---|---|---|---|
value * | string | Text written to the clipboard. | |
iconOnly | boolean | false | Square icon button; the label becomes its accessible name. |
label | string | 'Copy' | Button text before copying; the accessible name when iconOnly. |
copiedLabel | string | 'Copied!' | Replaces the label after a successful copy and is announced, until timeout resets it. |
errorLabel | string | 'Copy failed' | Replaces the label after a failed copy; announced together with the error message. |
animation | 'default' | 'spring' | 'default' | spring: the icons swap with a spin and a bounce, and the label slides between states. Combine with hoverScale / tapScale for the full micro-interaction. default: the theme's pop. |
variant | 'primary' | 'secondary' | 'ghost' | 'accent' | 'danger' | 'link' | Solid primary/accent/danger fill, outlined secondary, transparent ghost, or unpadded text link. | |
size | 'sm' | 'md' | 'lg' | Control height, padding and text size. | |
loading | boolean | Shows a spinner and blocks activation without changing the button's width: the spinner takes the left icon's place, or covers the label when there is no left icon. The button stays focusable and gets aria-busy. | |
fullWidth | boolean | Stretch to the full width of the container. | |
pill | boolean | Fully rounded ends, regardless of theme. | |
hoverScale | number | Scale under a hovering mouse, e.g. 1.05; it springs back with a slight bounce. Off by default (the theme's own hover). Skipped on touch and under reduced motion. | |
tapScale | number | Scale while pressed, e.g. 0.95, instead of the theme's press transform; springs back on release. | |
timeout | number | How long the copied/error state lasts, ms. | |
onCopy | (text: string) => void | ||
onError | (error: Error) => void |
Похожие компоненты
- Button — Кнопки всех типов
- Icon Button — Кнопка с иконкой
- Button Group — Группы кнопок
- Badge — Статусы и метки
- Avatar — Аватары пользователей
- Tooltip — Всплывающие подсказки
- Separator — Разделители
- Skeleton — Заглушки загрузки
- Spinner — Индикатор загрузки
- Progress Bar — Полосы прогресса
Назад: Button Group · Далее: Badge · Весь раздел «Базовые элементы»