Copy Button
A button that copies text to the clipboard, such as an invite code or a link, then says it did.
Installation
This also adds Button, which it draws, and Icon.
Usage
src/app/app.ts
- A tap copies
valuewithLynxClipboard. - For two seconds, it says "Copied" with a check icon, and a screen reader announces it.
- Android 13 and later show every copy themselves, in a panel at the bottom of the screen that TalkBack reads. There the button stays as it is, so the copy isn't announced twice.
Variants and sizes
It takes Button's variant and size:
A class places and sizes it, such as class="w-full" for a full-width button.
Icon only
With size="icon", it shows only its icon. Give it an accessibility-label for a screen reader to say. While the button shows the check, the label says "Copied" instead.
When it can't copy
copyFailed emits the ClipboardError, and the button says nothing. Lynx Explorer has no clipboard, so a copy there always fails. Run the app's own build instead (ng build --platform ios|android).
API
Accessibility
- A screen reader reads it as a button, with its label, or its
accessibility-label. - After a copy, it announces "Copied" (
copiedLabel), except on Android 13 and later, where TalkBack already says "Text copied".
Related
LynxClipboard: copy and read text yourself- Button: the button it draws
