#077
Interactive
A Surface rendered as a button that counts how many times it was pressed.
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "Interactive" pattern (@codeatlasdev/ui demo #077, surfaces/surface) in my app.
Call get_demo({ ids: ["#077"] }) first and keep its structure. It needs @codeatlasdev/[email protected].
Use: Custom clickable tiles or cards that need hover and press feedback while staying a native button.
Keep these library parts, with the props and tokens the demo uses:
- Surface from "@codeatlasdev/ui"
Behaviour to keep:
- `<Surface` with `as="button"`, `type="button"` and `interactive`
- Styling props: `elevation={2}`, `material="solid"`, `radius="md"`, `p="4"`
- Handler: `onclick={() => count++}`
- State: `let count = $state(0)`
- Label: `Pressed {count} times`
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
- Surface
@codeatlasdev/ui
How it is built
- `<Surface` with `as="button"`, `type="button"` and `interactive`
- Styling props: `elevation={2}`, `material="solid"`, `radius="md"`, `p="4"`
- Handler: `onclick={() => count++}`
- State: `let count = $state(0)`
- Label: `Pressed {count} times`
Related
Loading source.