Presets

Twitter like button animation

A heart that pops, fills with color and fires a ring burst when liked, Twitter-style.

CSSTailwindReactGIFMP4
00.000 / 0.450s
timing
style

npm i motion · the component uses motion/react

How it works

This like button animation reproduces the Twitter-style heart: tap it and the outline heart pops larger, fills with color, and a ring bursts out around it. Tap again and it returns to the outline.

Like the toggle and checkbox presets, it is a label wrapping a hidden checkbox, so the liked state is real form state. When checked, three things happen. The heart's fill and stroke transition from transparent and Outline color to Liked color over half the Duration. The heart runs a pop keyframe once: scale 1, then Pop scale at 40%, then back to 1. Behind it, a ring with a 2px border runs a burst keyframe from scale(0.2) at full opacity to scale(1.6) at zero, with fill-mode forwards so it stays invisible afterwards. Unchecking only reverses the color transition; there is no burst on unlike, which matches how social apps behave.

Parameters: Size, Liked color, Outline color, Pop scale, Duration and Easing. Pop scale of 1.2 to 1.4 feels lively; above 1.6 the heart overlaps nearby counters. Keep Duration around 0.4 to 0.5s.

The pop and burst use transform and opacity only. The label has aria-label="Like"; the checkbox announces checked or not checked, which screen readers relay as liked state. Update the like count in a separate live region if you show one.

How do I connect the like button to my backend?

Listen for the change event on the hidden checkbox (or use onChange in the React version) and send the new state to your API. Update the UI optimistically, since the animation already plays on click, and revert the checkbox if the request fails. Debounce rapid toggles so a double tap does not send two requests.

Why does the burst only play when liking?

The burst and pop are attached to the checked state with a single-iteration animation. When the input is unchecked, those animation rules no longer apply, so nothing plays; only the color transition runs back. Celebrating a like but not an unlike is the convention users expect from social apps.

Can I add particles like the original Twitter heart?

Yes, by adding several small dots around the heart that move outward and fade when checked, each with its own direction through a translate in its keyframe. Give them the same duration as the ring burst. The preset keeps a single ring to stay light, but the structure leaves room for extra elements.

relatedMore like this

all micro-interactions →
01 Toggle switch toggle
02 Animated checkbox toggle
03 Scroll down indicator loop
04 Spinner loop
05 Dual ring loop
06 Ripple loop

Export

format
height

480p max · small watermark · 3 per day · remove limits