Magnetic CTA
A call-to-action band with one large pill button.
Preview
Within a radius around it, the button is pulled toward the pointer on a spring, its label shifts a little further, a halo gathers behind it, and it squashes when pressed. With reduced motion turned on, it renders the plain layout.
Installation
Run this in a project that already uses shadcn/ui. It adds the component and anything it needs; the motion version also adds the plain one and the motion package.
Usage
import { MagneticCta } from "@/components/custom/magnetic-cta/magnetic-cta";
<MagneticCta
title="Ready when you are"
description="One button, hard to miss."
primaryAction={{ label: "Start building", href: "/signup" }}
secondaryAction={{ label: "or read the docs first", href: "/docs" }}
/>import { MagneticCtaMotion } from "@/components/custom/magnetic-cta/magnetic-cta-motion";
<MagneticCtaMotion title="Ready when you are" primaryAction={{ label: "Start building", href: "/signup" }} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title* (required) | string | – | The heading, rendered as an h2. |
| primaryAction* (required) | { label: string; href: string } | – | The large pill button. |
| secondaryAction | { label: string; href: string } | – | A quieter text link under the button. |
| description | string | – | Supporting line under the title. |
| ...props | React.ComponentProps<"section"> | – | Any other section attribute (id, aria-*, data-*, ref) goes to the root element. |
| Prop | Type | Default | Description |
|---|---|---|---|
| title* (required) | string | – | The heading, rendered as an h2. |
| primaryAction* (required) | { label: string; href: string } | – | The large pill button. |
| secondaryAction | { label: string; href: string } | – | A quieter text link under the button. |
| description | string | – | Supporting line under the title. |
| ...props | React.ComponentProps<"section"> | – | Any other section attribute (id, aria-*, data-*, ref) goes to the root element. |
Accessibility
- The button is a real link at least 56px tall; the text link under it is 44px tall.
- The magnetic pull is for mouse and pen only. With touch, keyboard or reduced motion it is a normal button in a fixed place.
- The motion version follows the visitor's reduced-motion setting and never hides content before it animates.