← Back to Challenge

Copy to Clipboard

Build a copy button using the async Clipboard API with visual feedback for success and error states.

Install commandnpm install @codesandbox/sandpack-react
API endpointhttps://api.example.com/v1/users?page=1&limit=10
Color token#1e293b
Git commandgit rebase -i HEAD~3

Use navigator.clipboard.writeText(text) — it returns a Promise. Set status to "copied" on resolve, "error" on reject, then reset after 2s with setTimeout.