Skip to content
VenusUI
Get started

Like Button

A heart toggle that pops and bursts when liked, with an optional count.

Preview

Installation

npx shadcn@latest add @venusui/like-button

Run this in a project set up with shadcn. If you haven’t set it up yet, run npx shadcn@latest init first.

Files added to your project

Paths use the default shadcn aliases. The CLI follows the aliases in your components.json.

  • @/components/ui/like-button.tsx

Usage

The code behind the preview above.

like-button-demo.tsx

import { LikeButton } from "@/components/ui/like-button"

export default function LikeButtonDemo() {
  return <LikeButton label="Like this post" count={128} />
}

API reference

PropTypeDefaultDescription
likedboolean—Controlled state.
defaultLikedbooleanfalseInitial state.
onLikedChange(liked: boolean) => void—Called on toggle.
countnumber—Count shown beside the heart; adjusts by one on toggle.
labelstring"Like"Accessible name, e.g. “Like this post”.

All <button> props except onChange.

Requirements

  • lucide-react, React 19 and Tailwind CSS v4. The CLI adds the keyframes.

Customization

  • Save likes on the server in onLikedChange and roll back if the request fails.

Accessibility

  • A toggle button with aria-pressed. The burst is decorative and skipped with reduced motion.

Troubleshooting

The count is off by one.
Pass the server count as count and let the button adjust it, or control both yourself.
Unknown registry "@venusui"
Your shadcn CLI couldn’t find the namespace in the shadcn registry index. Use the latest CLI (npx shadcn@latest), install by URL, or register it with its address: npx shadcn@latest registry add @venusui=https://venusui.com/r/{name}.json.
No components.json found
Run npx shadcn@latest init in your project first.
Loading preview

A card that tilts in 3D toward the pointer with spring physics.

Loading preview

Camera Shutter

Interactive

A lens with a working iris: blades close to the chosen aperture and snap shut when you release the shutter.

Loading preview

Stacked cards with the next ones peeking out; Next sends the top card to the back.