No.43 · Buttons
Follow Toggle
A follow button that changes its mind honestly: Follow becomes Following with a check, the pill narrows to fit, and hovering a followed state quietly offers Unfollow.
The prompt
The design brief behind this component — reuse it to regenerate, remix, or explain it.
Build a follow button with three labels in one pill — Follow (bone fill, + icon), Following (transparent with a hairline ring and a check that draws itself) and Unfollow (rose tint and ring, shown only when hovering a followed state, so the consequence is previewed before the click). All three labels are stacked in one grid cell and cross over with a 40% rise and a 3px blur resolving; the pill's width animates to the visible label's measured width (hidden copies, re-measured after fonts load) over 460ms expo-out. Following a person releases a faint ring that bursts outward from the pill and fades. Press compresses to 0.96. The accessible label says who you follow and what pressing will do; aria-pressed reflects state. 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 follow; hover while following to see Unfollow; click again to unfollow. Motion: Width 460ms; labels cross with blur and lift (260–420ms); check draw 420ms; follow burst 700ms. Accessibility: A toggle button with aria-pressed and a descriptive label; hidden label copies are aria-hidden. Reduced motion makes changes instant. Responsive behavior: Intrinsic width that follows the label. Touch: On touch there's no hover preview; tapping a followed state unfollows directly. 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 follow; hover while following to see Unfollow; click again to unfollow.
- Motion
- Width 460ms; labels cross with blur and lift (260–420ms); check draw 420ms; follow burst 700ms.
- Accessibility
- A toggle button with aria-pressed and a descriptive label; hidden label copies are aria-hidden. Reduced motion makes changes instant.
- Responsive
- Intrinsic width that follows the label.
- On touch
- On touch there's no hover preview; tapping a followed state unfollows directly.