Skip to content
IndexRequest a UIAboutContact

Double Tap to Like

Double tap or double click a photo to like it, with a heart that pops in at the tap point.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Create a photo card 280x180px (gradient placeholder) with a like button below it. Listen for pointerup on the photo: if a second pointerup happens within 300ms and within 30px of the first, treat it as a double tap. On a double tap, create a heart SVG at the tap position that animates scale 0.4 to 1.1 to 1 and fades out over 700ms with cubic-bezier(.3,1.4,.5,1), then remove it; also set the liked state to true if not already liked. The separate like button (44px, aria-pressed, aria-label "Like") toggles the liked state; when liked the heart is filled red and pulses scale 1 to 1.25 to 1 in 220ms. Display a like count that increments or decrements and announce it in an aria-live region. Prevent text selection and the native double-tap zoom on the photo with touch-action manipulation. Under prefers-reduced-motion use a 300ms fade without scaling.

About this pattern

Definition

A gesture where two quick taps on content register a like. A heart animates at the position of the second tap, and a regular like button stays available.

Purpose & UX principles

  • A quick, delightful shortcut popularised by photo feeds.
  • It is a shortcut only: the same action must exist as a labelled button with aria-pressed.
  • Double tapping never removes a like; it only adds one, so people cannot undo by accident.

Interaction states

  • Not liked, liked (filled heart, pressed), heart-pop animation, focus-visible on the button.

Motion specification

  • Pop heart: scale 0.4 to 1.1 to 1 with fade out, 700ms cubic-bezier(.3,1.4,.5,1).
  • Button heart: a 220ms scale pulse.
  • Reduced motion: the pop is replaced by a 300ms fade without scaling.

Responsive behaviour

  • Works with touch and mouse. Two taps within 300ms and 30px count as a double tap.
  • The like button is at least 44px.

Code

HTML
<div class="card">
  <div class="photo" id="photo" aria-label="Photo, double tap to like"></div>
  <div class="bar"><button class="like" id="like" aria-pressed="false" aria-label="Like"><svg viewBox="0 0 24 24" width="22" height="22" aria-hidden="true"><path d="M12 21s-7-4.6-9.5-9C.9 8.5 3 5 6.5 5c2 0 3.6 1.1 5.5 3 1.9-1.9 3.5-3 5.5-3C21 5 23.100 8.500 21.500 12 19 16.400 12 21 12 21z"/></svg></button><span id="cnt" aria-live="polite">128 likes</span></div>
</div>

Related patterns

Icon Button

↗
Icon ButtonButtons & Actions

Swipe to Delete

↗
Swipe to DeleteGestures & Touch

Long Press Menu

↗
Long Press MenuGestures & Touch