# ui: Add a \`CopyButton\` component \(\#45821\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/6d947b7746d77155f25d9fe357aaf67298344770)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 6d947b7746d77155f25d9fe357aaf67298344770

Requested commit: 6d947b7746d77155f25d9fe357aaf67298344770

Commit: 6d947b7746d77155f25d9fe357aaf67298344770

Tree: 8c8e4576b7c4daa0d64305b07f74088bc49402d7

Author: Danilo Leal

Committer: GitHub

## Message

````
ui: Add a `CopyButton` component (#45821)

There were several places adding a copy icon button, so thought of
encapsulating the logic to copy a given string into the clipboard (and
other small details like swapping the icon and tooltip if copied) into a
component, making it easier to introduce this sort of functionality in
the future, with fewer lines of code.

All it takes (for the simplest case) is:

```rs
CopyButton::new(your_message)
```

<img width="600" height="714" alt="Screenshot 2025-12-29 at 10  50@2x"
src="https://github.com/user-attachments/assets/e6949863-a056-4855-82d8-e4ffb5d62c90"
/>

Release Notes:

- N/A
````

## Parents

- [db221ca72dffac16c306a38744ac5606538ff7c9](https://git.cafe/gitcafe/zed/commit/db221ca72dffac16c306a38744ac5606538ff7c9?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/6d947b7746d77155f25d9fe357aaf67298344770?format=markdown)
