LikeButton

LikeButton is an animated like button component for React Native and React, from the dissolve library. Heart that pops with sparks on like and snaps into grains on unlike.

Like: the heart pops and ten sparks burst around it. Unlike: the filled heart snaps away into grains from its center and the outline is back.

Install

React Native

Install the engine once per app and wrap the root layout in <DissolveProvider> (see Installation), then copy the component into components/dissolve:

npx expo install dissolve-ui @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler expo-haptics
npx dissolve-ui add like-button --native
npx shadcn@latest add https://dissolve.rselmi.com/r/native/like-button.json

React

Needs React 19 and react-dom, nothing else: no engine, no provider, no Tailwind. Works in the Next.js App Router.

npx dissolve-ui add like-button --web
npx shadcn@latest add https://dissolve.rselmi.com/r/like-button.json

Usage

LikeButton.tsx (React Native)
import { useState } from 'react';
import { LikeButton } from '@/components/dissolve/like-button';

export function PostActions() {
  const [liked, setLiked] = useState(false);
  const [likes, setLikes] = useState(128);

  return (
    <LikeButton
      liked={liked}
      count={likes}
      onChange={(v) => {
        setLiked(v);
        setLikes((n) => n + (v ? 1 : -1));
      }}
    />
  );
}
LikeButton.tsx (React)
import { useState } from 'react';
import { LikeButton } from '@/components/dissolve/like-button';

export function PostActions() {
  const [liked, setLiked] = useState(false);
  const [likes, setLikes] = useState(128);

  return (
    <LikeButton
      liked={liked}
      count={likes}
      onChange={(v) => {
        setLiked(v);
        setLikes((n) => n + (v ? 1 : -1));
      }}
    />
  );
}

Props

PropTypeDefaultDescription
likedbooleanrequiredControlled state.
onChange(liked: boolean) => voidrequiredCalled with true right away on like, with false once the heart has snapped away.
sizenumber26Heart size in points.
colorstring'#FF2D55'Filled heart and counter when liked.
idleColorstringmuted tokenOutline and counter when not liked.
countnumberOptional counter shown next to the heart.
hapticsbooleantrueLight impact on like, the snap ticks on unlike.
classNamestring'flex-row items-center gap-1.5'Row: gap, padding, margins.
countClassNamestring'text-[15px] font-semibold'Counter text: size, weight.

Source

Previous: GlossyButton · Next: MorphButton · All components

dissolve is MIT licensed. Source on GitHub, package on npm. This page as markdown. For AI agents: llms.txt.