Pulsating Button
Install: npx shadcn@latest add https://jiguang132.com/r/magic-ui/pulsating-button.json
Use case
Display a native button with pulse or ripple decoration.
Native props used by the examples
Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.
| Owning component prop | Explanation | Example source |
|---|---|---|
PulsatingButton.children (pulsating-button) | Native child content; keep the owning component's text/element constraints. | examples/pulsating-button-demo.tsx、examples/pulsating-button-demo-2.tsx |
PulsatingButton.variant (pulsating-button) | Owning component's style/shape union; never substitute a universal variant API. | examples/pulsating-button-demo-2.tsx |
PulsatingButton.distance (pulsating-button) | PulsatingButton decoration reach as a CSS length. | examples/pulsating-button-demo-2.tsx |
PulsatingButton.className (pulsating-button) | Classes on this native component; initialize Tailwind and its required CSS first. | examples/pulsating-button-demo-2.tsx |
Interaction and state checks
- Pulsating Button Demo —
pulsating-button-demo - Pulsating Button Demo 2 —
pulsating-button-demo-2
These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.
Business integration boundary
variant is the native pulse/ripple union, unlike RainbowButton or the theme toggler. Wire real submission explicitly.
Host and motion setup
Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.
Available examples
pulsating-button-demo, pulsating-button-demo-2
Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.
Installation
<Tabs defaultValue="cli"> <TabsList> <TabsTrigger value="cli">CLI</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">npx shadcn@latest add @magicui/pulsating-button
</TabsContent>
<TabsContent value="manual">
<Steps>
<Step>Copy and paste the following code into your project.</Step>
<Step>Update the import paths to match your project setup.</Step>
<Step>Add the required CSS animations</Step>
Add the following animations to your global CSS file.
@theme inline {
--animate-pulse: pulse var(--duration) ease-out infinite;
--animate-pulse-ripple: pulse-ripple var(--duration)
cubic-bezier(0.16, 1, 0.3, 1) infinite;
@keyframes pulse {
0%,
100% {
box-shadow: 0 0 0 0 var(--pulse-color, oklch(from var(--bg) l c h / 0.5));
}
50% {
box-shadow: 0 0 0 var(--distance)
var(--pulse-color, oklch(from var(--bg) l c h / 0.5));
}
}
@keyframes pulse-ripple {
0% {
box-shadow: 0 0 0 0 oklch(from var(--pulse-color, var(--bg)) l c h / 1);
}
100% {
box-shadow: 0 0 0 var(--distance)
oklch(from var(--pulse-color, var(--bg)) l c h / 0);
}
}
}
</Steps>
</TabsContent>
</Tabs>
Usage
import { PulsatingButton } from "@/components/ui/pulsating-button"
<PulsatingButton>Pulsating Button</PulsatingButton>
Examples
Ripple Variant
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | The content of the button. |
className | string | - | Additional class names for the button. |
pulseColor | string | Derived from button background | Any valid CSS color for the pulsing waves. |
duration | string | 1.5s | The duration of one pulse. |
distance | string | 8px | How far the pulse expands from the button. |
variant | "pulse" | "ripple" | pulse | The pulse animation style. |
Credits
- Credit to @shikhap04 & @abdmjd1
Complete example installation
The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.
Pulsating Button Demo
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/pulsating-button/pulsating-button-demo.json
Default import: @/components/magicui/examples/pulsating-button-demo
Dependencies: clsx@2.1.1, tailwind-merge@3.6.0
Pulsating Button Demo 2
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/pulsating-button/pulsating-button-demo-2.json
Default import: @/components/magicui/examples/pulsating-button-demo-2
Dependencies: clsx@2.1.1, tailwind-merge@3.6.0
Minimal usage and theme
import Demo from '@/components/magicui/examples/pulsating-button-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}
Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.
Source-backed parameter reference
Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.
PulsatingButton({
className,
children,
pulseColor,
duration = "1.5s",
distance = "8px",
variant = "pulse",
...props
}, ref)
interface PulsatingButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
pulseColor?: string
duration?: string
distance?: string
variant?: "pulse" | "ripple"
}
Destructuring defaults in source
Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.
// PulsatingButton
duration = "1.5s"
// PulsatingButton
distance = "8px"
// PulsatingButton
variant = "pulse"
Native and external types
External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.
HTMLButtonElement
React.ButtonHTMLAttributes<HTMLButtonElement>