Heart Icon
NewBeats on hover. Pops full with a small burst when liked.
motion@soultel/use-reduced-motion-safe@soultel/use-icon-trigger
hover me
Installation
$ pnpm dlx shadcn@latest add @soultel/icon-heartNo namespace set up? npx shadcn@latest add https://asafefe.dev/r/icon-heart.json works too.
Manual installation
- 1. Install the dependencies.
terminal1 lines npm install motion - 2. Copy the source from the Code tab into components/icon-heart.tsx.
Usage
import { useState } from "react"
import { HeartIcon } from "@/components/icon-heart"
export function LikeButton() {
const [liked, setLiked] = useState(false)
return (
<button onClick={() => setLiked(!liked)} aria-pressed={liked} aria-label="Like">
<HeartIcon active={liked} className={liked ? "text-primary" : ""} />
</button>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| active | boolean | false | Fills the heart. |
| size | number | 24 | Width and height in px. |
| strokeWidth | number | 2 | Stroke width on the 24 by 24 grid. |
| animate | "hover" | "always" | boolean | "hover" | "hover" plays when the nearest button or link (or the icon) is hovered, focused or tapped. "always" loops. A boolean plays each time it turns true, so a parent can drive it. |
| label | string | - | Accessible name. Without one the icon is aria-hidden. |
| className | string | - | Classes for the svg. Color comes from currentColor. |
