Heartbeat Icon

PreviousNext

Continuous heartbeat rhythm animation for icons

Docs
animbitscomponent

Preview

Loading preview…
registry/new-york/animations/icons/heartbeat.tsx
"use client";
import * as motion from "framer-motion/client";
import type { HTMLMotionProps } from "motion/react";
import { heartbeatVariants } from "@/lib/animation-presets";
interface HeartbeatIconProps extends Omit<HTMLMotionProps<"div">, "animate"> {
  children: React.ReactNode;
  bpm?: number;
}
export function HeartbeatIcon({
  children,
  bpm = 60,
  ...props
}: HeartbeatIconProps) {
  const duration = 60 / bpm;
  return (
    <motion.div
      variants={heartbeatVariants}
      initial="initial"
      animate="animate"
      transition={{
        duration,
        ease: "easeInOut",
        repeat: Infinity,
      }}
      {...props}
    >
      {children}
    </motion.div>
  );
}

Installation

npx shadcn@latest add @animbits/icons-heartbeat

Usage

import { IconsHeartbeat } from "@/components/icons-heartbeat"
<IconsHeartbeat />