#100
In a button
A Button that shows its loading spinner for two seconds after click and changes its label to Saving.
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "In a button" pattern (@codeatlasdev/ui demo #100, feedback/spinner) in my app.
Call get_demo({ ids: ["#100"] }) first and keep its structure. It needs @codeatlasdev/[email protected].
Use: Save or submit buttons that wait on a request.
Keep these library parts, with the props and tokens the demo uses:
- Button from "@codeatlasdev/ui"
Behaviour to keep:
- `<Button onclick={simulate} {loading}>` with `let loading = $state(false)`
- `simulate` sets `loading = true` and resets it with `setTimeout(() => (loading = false), 2000)`
- Label is `{loading ? 'Saving…' : 'Save changes'}`
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
- Button
@codeatlasdev/ui
How it is built
- `<Button onclick={simulate} {loading}>` with `let loading = $state(false)`
- `simulate` sets `loading = true` and resets it with `setTimeout(() => (loading = false), 2000)`
- Label is `{loading ? 'Saving…' : 'Save changes'}`
Related
Loading source.