Componentform0.8 KB gzipZero dependencies
LikeButton
Heart/thumb button that fills on click with burst particle animation and count increment.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add like-buttonOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { LikeButton } from "@/components/ui/like-button"; <LikeButton onClick={handleLike} />Source code
like-button.tsx + 2 helpersZero 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 />| Prop | Type | Description |
|---|---|---|
| active | boolean | Toggles active. |
| defaultActive | boolean | Toggles default active. |
| initiallyActive | boolean | Toggles initially active. (Default: false) |
| count | number | Configures count. |
| onActiveChange | (active: boolean) => void | Callback invoked on active change. |
| onClick | (active: boolean) => void | Callback when button is clicked. |