How to announce the result of an icon-only copy command
Answer in brief
Keep focus on the copy button and update a status region with the result after the copy succeeds. Give failures their own message so the feedback matches the outcome.
Test repeat copies
Render an initially empty element with role="status". Copy a code sample and populate it with “Code copied”. Repeat on another sample and verify the announcement identifies the new result without moving focus away from the command.
Handle delayed clipboard results
If copying takes a moment, changing the icon to a success check immediately can give false feedback. Wait for the clipboard operation to resolve, then update the announcement. Exercise the failure path by denying clipboard permission in a test profile and verify that the old success message clears.
Sources
- [1] ARIA: status role - ARIA — MDN Web Docs, accessed November 23, 2026
Frequently asked questions
Should the checkmark image carry the announcement?
The status message can supply the complete feedback. Treat a checkmark beside that message as decoration.