Componentes/CopyButton

CopyButton

Botão de copiar para clipboard com feedback visual. Ícone copy → check ao clicar, com transição de cor. 2 tamanhos (default 28px, sm 20px).

Outros
Figma:

Preview

Default (28px)
Small (20px)

Código

Copie e cole no Claude Code para implementar este componente em pixel-perfect usando os tokens TRDR.

<!-- Default -->
<button class="trdr-copy-btn" title="Copiar">
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
    <rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
    <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
  </svg>
</button>

<!-- Small -->
<button class="trdr-copy-btn trdr-copy-btn-sm" title="Copiar">
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
    <rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
    <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
  </svg>
</button>

<!-- Estado copiado (class .copied) -->
<button class="trdr-copy-btn copied" title="Copiado!">
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
    <polyline points="20 6 9 17 4 12" />
  </svg>
</button>

Dimensões

VarianteLarguraAltura
Default28px28px
Small20px20px

Props / Variantes

PropTipoValores
Sizeenum
DefaultSmall
Stateenum
IdleCopied

Tokens Utilizados

PropriedadeTokenValor
Icon colorcontent-tertiary
#A4A4A4
Icon hovercontent-primary
#FFFFFF
BG hoversurface-secondary
#222222
Border hoverborder-default
#4A4A4A
Copied colorcontent-success
#4FE290
Copied BGsurface-success
#4FE29014
Copied bordercontent-success
#4FE290
Border radiusradius-sm
4px

Anatomia

[button.trdr-copy-btn .trdr-copy-btn-sm?]
  └── [svg 14×14 (default) / 12×12 (sm)]
        ├── idle: ícone copy (rect + path)
        └── copied: ícone check (polyline)

Default: 28×28px, border-radius radius-sm, bg transparent, border 1px transparent
Small: 20×20px, svg 12×12px
Hover: icon primary, bg surface-secondary, border border-default
Copied: icon + border content-success, bg surface-success — auto-reset 1.5s