Kinetik UI

Magnet Button

.md

A button that leans toward the finger from a field around it and presses on release.

v1.0.0Live on webreact-native-gesture-handlerreact-native-reanimatedreact-native-worklets
Component preview

Installation

Kinetik CLI
npx kinetik-ui add magnet-button

The CLI copies the source and installs native dependencies with npx expo install, so versions match your Expo SDK. With shadcn: npx shadcn@latest add https://kinetik-ui.dev/r/magnet-button.json

Install manually

  1. Install dependencies
    npx expo install react-native-gesture-handler react-native-reanimated react-native-worklets
  2. Copy the source files
    • components/kinetik/magnet-button.tsx
    View source files

Usage

import { MagnetButton } from '@/components/kinetik/magnet-button';

<MagnetButton onPress={start}>Get started</MagnetButton>;

Touching anywhere in the field around the button (40 pt by default) pulls it toward the finger. Releasing over the button presses it; releasing elsewhere lets it spring back.

When to use

  • A hero call to action with space around it: landing, onboarding, empty states.
  • Playful products where the button can invite the finger in.

When not to use

  • Tight layouts. The field reaches into neighbouring elements and needs room.
  • Rows of buttons. Fields overlap and the pulls compete.

Notes

  • The field uses negative margins, so it does not change your layout. Give the button at least field points of free space on each side.
  • The touch tracking never claims the gesture, so the button works inside scroll views.
  • Reduced motion keeps the button still and only dims it under the finger.
  • The button sizes to its label. Position it with style, e.g. style={{ alignSelf: 'center' }}.

Props

MagnetButtonProps

PropTypeDefaultDescription
childrenrequiredReactNode—Button label. A string gets the variant's text style; any node is rendered as is.
onPress() => void—
variant'ember' | 'surface''ember'Defaults to `ember`.
strengthnumber0.5How strongly the button follows the finger, 0–1. Defaults to 0.5.
fieldnumber40Width of the invisible field around the button that attracts the finger, in pt. Defaults to 40.
maxPullnumber14Maximum distance the button travels toward the finger, in pt. Defaults to 14.
hapticsbooleantruePlays a tick when the finger is captured and a tap on press. Defaults to true.
disabledbooleanfalse
accessibilityLabelstring—Required when `children` is not a string.
accessibilityHintstring—
styleStyleProp<ViewStyle>—

Performance and accessibility

Performance

Budget
Touch moves retarget two springs on the UI thread; nothing runs at rest.
Measured

Pixel 9 emulator, API 35, release build · interaction median 1.05× the system Settings app on the same emulator (indicative only) · no frames drawn at rest · 149 MB app memory

Real-device measurement pending.

Accessibility

Reduced motion
The button stays put and only dims slightly while the finger is over it.
Screen readers
Button role; 'activate' presses it.
Touch target
At least 52 pt tall; the field adds 40 pt of reach on every side.

Source files

components/kinetik/magnet-button.tsx is in the Code tab of the preview above.