#148
clipboard
A native button that copies an install command to the clipboard and shows a Copied! label for two seconds.
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "clipboard" pattern (@codeatlasdev/ui demo #148, navigation/actions) in my app.
Call get_demo({ ids: ["#148"] }) first and keep its structure. It needs @codeatlasdev/[email protected].
Use: Copy-to-clipboard affordances for install commands, API keys and share links.
Keep these library parts, with the props and tokens the demo uses:
- clipboard from "@codeatlasdev/ui/actions"
Behaviour to keep:
- `use:clipboard={'bun add @codeatlasdev/ui'}` imported from `@codeatlasdev/ui/actions` on a native `<button`
- `oncopy={done}` sets `copied = true` and resets it with `setTimeout(() => (copied = false), 2000)`
- Label switches with state: `{copied ? 'Copied!' : 'Copy install command'}`
- `let copied = $state(false)`
Reduced motion: the demo handles it; keep that branch.
Keyboard: operable; keep the focus order and key handling.
Change only the copy and the data. Use the theme tokens (--ca-*), never raw colours. Library parts
How it is built
- `use:clipboard={'bun add @codeatlasdev/ui'}` imported from `@codeatlasdev/ui/actions` on a native `<button`
- `oncopy={done}` sets `copied = true` and resets it with `setTimeout(() => (copied = false), 2000)`
- Label switches with state: `{copied ? 'Copied!' : 'Copy install command'}`
- `let copied = $state(false)`
Related
Loading source.