A stunning CSS & SVG heart beat animation with pulsating veins, perfect for creating engaging UI effects.
Heart Beat Animation
This component showcases a heart beat animation using SVG and CSS.
The heart pulses with animated borders and veins to create a lively, realistic heartbeat effect.
🔹 Features
- Pure **SVG & CSS**, no JavaScript required
- Animated **heart pulse** with veins
- Dark mode support
- Fully responsive
>
📦 Usage
HTML
```html
```
The heart animation uses a scalable vector graphic (SVG) as the main container. Inside, there are multiple reusable shapes defined as symbols. One symbol represents the heart’s outer border, and four additional symbols represent inner veins. The elements are grouped into layers: the outer border with a faint pulse effect and the inner veins with animated flow. The SVG also includes accessibility labels describing the heart and its movement for screen readers.
The styles start by resetting default margins and paddings. CSS variables are used to define theme colors and transition durations. The body is styled to center content using flex, with smooth background and color transitions. Font sizes are responsive, adjusting slightly based on viewport width.
2 Heart Styles
The heart itself is centered and scaled proportionally. Its color is controlled by a CSS variable. Border and vein elements are animated infinitely, with smooth easing for natural motion. Groups of veins are animated together, with their origin points set to specific locations for realistic movement.
3 Border and Vein Animations
The heart border grows and shrinks to simulate a heartbeat. Additional border animations create a fading glow effect. Each vein has three types of animation: fade, offset, and pulse. Fade controls the visibility, offset animates along the path for flow, and pulse rotates the vein slightly to add dynamic motion. These animations repeat indefinitely to create a continuous heartbeat effect.
4 Dark Mode Support
The animation automatically adjusts for dark mode using a media query. The background, text, and heart colors change to maintain contrast and visual appeal.
5 How the Animation Works Together
The outer heart layer pulses and glows, while the inner veins appear sequentially, move along paths, and rotate slightly. This combination gives the illusion of a living, beating heart with blood flowing inside. The effect is fully responsive and accessible, and it works on light and dark themes.