No.28 · Buttons
Tally Button
A save or like button whose count turns like an odometer: only the digits that change roll, one after another from the left, while a ring leaves the icon as it fills.
The prompt
Written for the variant you picked above: Night
Build a pill toggle for saving or liking: an outline icon (bookmark or heart), the verb, a hairline divider and the count. Render the count as odometer reels: one 1em-tall window per digit holding a 0–9 strip translated to −digit em, keyed by place from the right, so places keep their identity when the number grows. When the count changes, compare each place with the previous value. Only changed digits transition (560ms expo-out), and each changed digit waits 70ms more than the changed digit to its left, so 1,299 → 1,300 rolls the three wheels in a small cascade while the thousands stay still. A new leading place (99 → 100) grows in from zero width. Separators never move. Pressing fills the icon in amber with a springy 1.12 scale and sends a thin ring out from it (scale 0.6 → 1.5, fading), tints the face and count, and changes 'Save' to 'Saved'. It's a toggle with aria-pressed and an accessible name like 'Save, 1,300 saves'. Selected variant — Night (night): Palette for this theme (Night): --tlb-edge rgb(239 232 220 / 0.14); --tlb-face #141217; --tlb-ink #efe8dc; --tlb-muted #9c96a1; --tlb-on #f0b37a; --tlb-on-face #1d1712. Treat these as the root colour tokens, one value per role, and name them to suit your code. Select it with the theme option set to "night". Keep every dimension, spacing value, state and motion from the brief unchanged, and keep text at 4.5:1 contrast or better on these surfaces. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Click to save or like; click again to undo. The changed digits roll in order. Motion: Digit roll 560ms expo-out, +70ms per changed place; icon spring 420ms; ring 620ms. Accessibility: A real toggle with aria-pressed and a full accessible name including the current count; the reels, icon and visible text are aria-hidden so the name isn't read twice. Reduced motion swaps digits instantly. Responsive behavior: Intrinsic width; tabular numerals keep the count from jittering. Touch: Same on touch. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.
Notes
- Interaction
- Click to save or like; click again to undo. The changed digits roll in order.
- Motion
- Digit roll 560ms expo-out, +70ms per changed place; icon spring 420ms; ring 620ms.
- Accessibility
- A real toggle with aria-pressed and a full accessible name including the current count; the reels, icon and visible text are aria-hidden so the name isn't read twice. Reduced motion swaps digits instantly.
- Responsive
- Intrinsic width; tabular numerals keep the count from jittering.
- On touch
- Same on touch.