Ir al contenido
Español
Botón magnético viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

A transparent sensing area wraps the button. While the pointer moves inside it, the button shifts by pointer-to-center distance × strength, and the label shifts a further 30% for depth. Following uses a 140ms ease-out to feel immediate; leaving uses a 600ms spring. Mouse only: touch and reduced motion do not move it.

Úsalo para

  • The single most important call to action on a landing or campaign page.
  • A guiding button inside an empty state.

Busca otra opción cuando

  • Frequent buttons such as form submit or list actions: the movement hurts click accuracy.
  • More than one per screen: several moving buttons feel restless.

Uso

import { MagneticButton } from './MagneticButton.jsx'

export function Hero() {
  return (
    <MagneticButton strength={0.35} onClick={() => startTrial()}>
      Try it now
    </MagneticButton>
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
strengthnumber0.35Pull strength from 0 to 1: how far the button follows the pointer.
radiusnumber28Sensing range in px: how close the pointer must be to the button edge before it is pulled.
variant'solid' | 'outline' | 'ink''solid'Visual style: accent-filled solid, a raised outline with a hairline ring, or ink (text colour, inverts in dark). Each opens a soft 6px halo while pulled.
...restButtonHTMLAttributes—Other attributes go to the <button>, such as onClick and disabled (a disabled button neither pulls nor shows hover).

Accesibilidad

  • Keyboard focus shows a focus ring and causes no movement.
  • Touch devices get no pull.
  • With reduced motion the button does not move; hover colour and shadow still appear while the pointer is on it.

Movimiento

Follow: 140ms ease-out. Return: 600ms spring. Halo opens to 6px and the shadow deepens in 240ms ease-out; a trailing icon leans 2px forward. Press scales to 0.96.

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

MagneticButton.jsxmagnetic-button.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Botones
Botón de borde aurora viene con Pro. La vista previa aparece al desbloquearlo.
Botón con mordiscos viene con Pro. La vista previa aparece al desbloquearlo.