Pulsating Button
A button component with a pulsating ring effect that continuously expands and fades around the button, creating an attention-grabbing animation. Perfect for call-to-action buttons or highlighting important actions.Installation
Usage
Examples
Basic Usage
Custom Pulse Color
Custom Duration
Custom Styling with All Props
Props
The content to display inside the button.
Additional CSS classes to apply to the button.
The color of the pulsating ring effect. Accepts any valid CSS color value (hex, rgb, hsl, etc.).
The duration of one complete pulse animation cycle. Accepts any valid CSS duration value (e.g., “1s”, “2000ms”).
All standard HTML button attributes are supported (onclick, disabled, type, etc.).
Component Details
Animation Behavior
The Pulsating Button creates a continuous pulse effect through:- Ring Expansion: A duplicate element expands from the button’s center
- Box Shadow Animation: The shadow grows from 0 to 8px while fading out
- Infinite Loop: The animation repeats continuously with an ease-out timing function
Keyframe Animation
The component requires this CSS keyframe animation (automatically included via registry):CSS Variables
The component uses these CSS custom properties:--pulse-color: Controls the color of the pulsating ring--duration: Controls the animation duration
CSS Classes
Default classes applied:- Base:
bg-primary text-primary-foreground relative flex cursor-pointer items-center justify-center rounded-lg px-4 py-2 text-center - Pulse ring:
animate-pulse-ring absolute top-1/2 left-1/2 size-full -translate-x-1/2 -translate-y-1/2 rounded-lg bg-inherit - Content wrapper:
relative z-10
Dependencies
- Tailwind CSS - For styling and animations
- Custom animation keyframe - Included via registry
Accessibility
The pulsating effect is purely decorative and doesn’t affect button functionality or accessibility.
- Semantic
<button>element - Keyboard navigation support
- Screen reader compatible
- Focus states
- All ARIA attributes supported
Use Cases
The Pulsating Button is ideal for:- Call-to-action buttons: Draw attention to primary actions
- Notification triggers: Indicate new or important content
- Live status indicators: Show active or real-time features
- Promotional elements: Highlight special offers or features