# CopyButton
> One-click clipboard copy button — new in v0.3.0.
Source: https://shellui.dev/docs/v0.4/components/advanced/copy-button
`CopyButton` is **new in v0.3.0**. It copies text to the clipboard via the browser's Clipboard API and gives visual feedback with a checkmark icon for ~2 seconds after copying.
## Installation
```bash
shellui add copy-button
```
## Usage
### Basic
```razor
```
### In a code block header
```razor
bash
dotnet tool install -g ShellUI.CLI
```
### With callback
```razor
@inject ISonnerService Sonner
@code {
private string _apiKey = "sk-abc123";
private void HandleCopied() => Sonner.Success("API key copied!");
}
```
### With custom icon
Replace the default clipboard icon by providing `ChildContent`:
```razor
@code {
private string value = "dotnet tool install -g ShellUI.CLI";
}
```
## API Reference
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `Text` | `string?` | `null` | The text to copy to clipboard |
| `ChildContent` | `RenderFragment?` | `null` | Custom icon (default clipboard SVG used if omitted) |
| `Class` | `string?` | `null` | Additional CSS classes |
| `OnCopied` | `EventCallback` | — | Fired after successful copy |
## Notes
- Requires a secure context (HTTPS or localhost) — the browser Clipboard API is unavailable on plain HTTP.
- The button is automatically disabled while the copy is in progress to prevent double-clicks.