ValyroUI English version

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';

Пропсы

PropTypeDefault
value *stringText written to the clipboard.
iconOnlybooleanfalseSquare icon button; the label becomes its accessible name.
labelstring'Copy'Button text before copying; the accessible name when iconOnly.
copiedLabelstring'Copied!'Replaces the label after a successful copy and is announced, until timeout resets it.
errorLabelstring'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.
loadingbooleanShows 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.
fullWidthbooleanStretch to the full width of the container.
pillbooleanFully rounded ends, regardless of theme.
hoverScalenumberScale 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.
tapScalenumberScale while pressed, e.g. 0.95, instead of the theme's press transform; springs back on release.
timeoutnumberHow 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 · Весь раздел «Базовые элементы»