ButtonsNew

Magnetic Button

The button pulls toward the cursor when the mouse is near and springs back. Turns itself off on touch screens.

Customize

color
glowColor
highlightColor

Based on Magnetic Button (MIT license) ยท Terms of use

More in Pro

View all

Props

11 properties
PropertyTypeDefaultDescription
strengthnumber0.3How strongly the button pulls toward the cursor.
radiusnumber150Distance at which the pull starts, in pixels.
variant'default' | 'secondary' | 'outline' | 'ghost' | 'link' | 'destructive'"default"Button style.
size'default' | 'sm' | 'lg' | 'icon'"default"Button size.
disabledbooleanfalseDisable the button and the effect.
springConfig{ duration?: number; bounce?: number }"{ bounce: 0.1, duration: 0.4 }"Spring settings.
asChildbooleanfalsePass the styles to the child, e.g. a link.
childrenReactNodeโ€”Button text and icon.
colorstring"#ffffff"Fill color of the button. Text turns dark or white on its own.
glowColorstring"rgba(255,255,255,0.25)"Soft glow under the button.
highlightColorstring"rgba(255,255,255,0.6)"Thin sheen along the top edge.

Dependencies

5 required packages

npm install motion @radix-ui/react-slot class-variance-authority clsx tailwind-merge

Related components

View all