Componentform0.8 KB gzipZero dependencies

LikeButton

Heart/thumb button that fills on click with burst particle animation and count increment.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add like-button

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { LikeButton } from "@/components/ui/like-button"; <LikeButton onClick={handleLike} />

Source code

like-button.tsx + 2 helpers

Zero third-party dependencies (3 local files shown in tabs below).

tsxlike-button.tsx79 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils";import { useControllableState } from "./lib/use-controllable-state"; export interface LikeButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> {  active?: boolean;  defaultActive?: boolean;  initiallyActive?: boolean;  count?: number;  onActiveChange?: (active: boolean) => void;  onClick?: (active: boolean) => void;} export const LikeButton = React.forwardRef<HTMLButtonElement, LikeButtonProps>(function LikeButton(  {    active: controlledActive,

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { LikeButton } from "@/components/ui/like-button"; <LikeButton />
PropTypeDescription
activebooleanToggles active.
defaultActivebooleanToggles default active.
initiallyActivebooleanToggles initially active. (Default: false)
countnumberConfigures count.
onActiveChange(active: boolean) => voidCallback invoked on active change.
onClick(active: boolean) => voidCallback when button is clicked.