Like button
A selectable heart with an independent fill sweep, pop, particle burst and rolling total.
npx @swipeui/cli add like-buttonWhen to use it
- Toggle a single like and show its total.
- Offer independent animation and count presentation settings.
When not to use it
- Replace a reaction picker with several meanings.
- Assume a controlled count excludes the current user vote.
Installation
Installs with a Pro licence
Everything on this page is public except the source. Founder pre-sale opens around 5 January 2027.
Usage
import { LikeButton } from '@/components/swipeui/ui/like-button';
<LikeButton
liked={liked}
onLikedChange={setLiked}
count={count}
onCountChange={setCount}
burst
pop
fillSweep
/>;Examples
post, counts, quiet. The app and public preview use the same content and variant names. Demo settings sit outside the component and outcome feedback stays on the action.
Settings
| Setting | Default | Behavior |
|---|---|---|
showCount | true | Show the rolling total beside the heart. |
countMotion | true | Animate changed count digits independently. |
formatCount | localized integer | Exact count formatter; no numeric parsing follows formatting. |
minCountWidth | 32 | Minimum count footprint in points; allows large totals to grow. |
liked | undefined | Controlled selection. |
defaultLiked | false | Initial uncontrolled selection. |
onLikedChange | undefined | Receives selection intent; caller owns remote persistence. |
count | undefined | Controlled displayed total, including this user's vote when selected. |
defaultCount | 0 | Initial uncontrolled total. |
onCountChange | undefined | Receives the proposed total after an accepted toggle. |
adjustCount | true | Increment/decrement the count on local selection intent. |
burst | true | One-shot particles on a fresh like. |
pop | true | Pop the heart on a fresh like. |
fillSweep | true | Reveal selected fill from the bottom edge. |
disabled | false | Block selection. |
haptics | true | Selection haptic on accepted toggles. |
motion | app feel | Shared feel; Reduce Motion removes pop/particles and switches fill directly. |
variant | ghost | Shared surface style. |
tone | primary | Shared selected/outline/count tone. |
size | 'md' | The height: sm 36pt (with a 44pt touch target), md 44pt, lg 52pt. |
shape | 'preset' | preset follows your preset's control radius; pill is a capsule. |
block | false | Stretches the button to the full width of its container. |
leadingIcon | absent | Content before the label: a node, or a function that receives { color, size }. |
trailingIcon | absent | Content after the label: a node, or a function that receives { color, size }. |
trailingIconNudge | false | Slides the trailing icon a little forward while pressed, mirrored in right-to-left layouts. |
loading | false | Shows a spinner, reports busy and ignores taps. |
loadingLabel | absent | Label shown while loading; defaults to the children. |
loadingPlacement | 'start' | Where the spinner goes: start replaces the leading icon; center hides the label and holds the width. |
labelMorph | 'fade' | How a changed text label arrives: fade (the new label rises in as the old one fades), characters (only the changed letters roll in) or none. The width springs to fit either way. |
highlight | true | A faint rim of light along the top edge of solid buttons. |
glow | false | A soft shadow in the tone's colour under solid buttons. |
pressEffect | 'both' | Feedback while pressed: both scales and washes the surface, scale, wash or none. Text-only buttons dim their label instead of washing. |
disabledStyle | 'muted' | How a disabled button looks: muted mutes its fill and label; dim halves its opacity. |
palette | BUTTON_PALETTE | Colours that belong to the button's material rather than the theme (the top highlight). |
className | absent | Classes merged over the style. |
textClassName | absent | Classes for the label text. |
style | absent | Style escape hatch for the container. |
accessibilityLabel | current label | Optional spoken-name override. |
testID | undefined | Root identifier; parts append suffixes. |
Composition and behavior
Use onLikedChange/onCountChange for local intent and control liked/count plus loading during remote persistence. The callbacks do not provide an async persistence engine. Counts clamp to finite nonnegative safe integers; formatCount returns exact display text. Independent effects never mutate selection or counts.
liked and count are independently controlled. count is the displayed total, including the selected vote; onCountChange reports local proposed totals.
adjustCount can stop automatic total intent. showCount, countMotion, formatCount and minCountWidth configure presentation separately.
A fresh like triggers independent pop and burst; initial selected state does not burst. fillSweep reveals the authored selected heart. Reduce Motion removes decorative travel and particles while keeping feedback.
API reference
Review gates
Founder app and existing pnpm-dev visual acceptance remains open. Native runtime, VoiceOver/TalkBack, haptics, motion, Dynamic Type, RTL and recordings remain pending founder-scheduled 7.9. Source, bundle and unit checks do not establish visual or native acceptance.
| Setting | Default | Behavior |
|---|---|---|
heartTone | destructive | Heart/particles color independently of the count and surface. |
doubleTapToLike | true | A rapid pair of activations ends liked instead of toggling off. Single activation stays immediate. |
doubleTapDelay | 300 | Pairing window in milliseconds; a content clock, independent of motion feel. |
The photo accepts a double-tap/click with an authored heart cue. It requests a like only when needed, so repeating it preserves the total. Single action/keyboard activation remains available on the actual Like button.
Behavior and gestures
- liked and count are independently controlled. count is the displayed total, including the selected vote; onCountChange reports local proposed totals.
- adjustCount can stop automatic total intent. showCount, countMotion, formatCount and minCountWidth configure presentation separately.
- A fresh like triggers independent pop and burst; initial selected state does not burst. fillSweep reveals the authored selected heart. Reduce Motion removes decorative travel and particles while keeping feedback.
- The heart and particles use destructive red independently of the count. Rapid paired activations like instead of toggling off; doubleTapToLike and its content-time window are independent settings. Double-tapping the photo shows an authored heart feedback cue.
Accessibility
- Named controls expose unavailable, busy and selected/progress state where applicable. Decorative layers are excluded from interaction.
- Meaningful outcome/availability announcements are distinct from clocks and decorative effects. Native VoiceOver/TalkBack, Dynamic Type, RTL and touch evidence remain pending for 7.9.
Motion
- Uses the
press,morphandnumbermotion roles, so it follows your app's feel. Passmotionto tune this one instance. - Every decorative duration/spring comes from the shared role helpers. Content clocks remain independent of motion feel.
- Reduce Motion retains readable outcome/progress feedback. Native motion/performance review remains pending.
Performance
- No new package, network service, telemetry or proprietary source.
- Async results and content timers clean up or invalidate after unmount; UI animation values stay on the UI thread.
Notes for AI
- Use onLikedChange/onCountChange for local intent and control liked/count plus loading during remote persistence. The callbacks do not provide an async persistence engine. Counts clamp to finite nonnegative safe integers; formatCount returns exact display text. Independent effects never mutate selection or counts.
- Founder app/web acceptance and all native runtime, accessibility, haptics, motion and recordings remain pending for 7.9.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.