Wrap one child, and put a MagneticLayer around a part that must move more than the item, such as the arrow.
The sample also uses Button. One command adds them with this item:
start-trial-button.tsx
Magnetic
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| strength | number | — | The share of the pointer distance from the center that the item moves: 0.3 moves it 3px for each 10px. The pull grows with the size, so lower it for a large item (0.06 for a card). In a row, the item reaches past its edge toward the pointer (about 16px for a 140px button at 0.3): keep the gap to a neighbour larger, or lower strength or range, or it covers the neighbour. |
| range | number | — | How far outside the edge the pull starts, in px. 0 pulls only while the pointer is on the item. |
| axis | "both""x""y" | — | x or y moves the item on one axis only (a nav link that must stay on its line). |
| disabled | boolean | false | Springs the item home and stops the pointer work. |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
MagneticLayer
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| depth | number | 2 | How far the layer moves, as a multiple of the item pull: 2 moves it twice as far as the item (an icon that floats ahead), 1 with the item, 0 keeps it still on the page, and below 0 it moves against the pull. |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |







