Component packs › Ferro › Magnet Toggle

Magnet Toggle

The knob is a magnet: switch on and the steel balls in the track jump up and cling to it; switch off and they drop, bounce and roll home.

Magnet Toggle is a switch from Ferro, a component pack with 7 components: Components that behave like magnets. Price: $5 for the whole pack.

Built with: ball physics, cling and drop, role switch.

Code: React and Next.js (TypeScript), Vue 3, plain HTML/CSS/JS, Tailwind CSS v4 and Motion (motion.dev). No npm packages needed. Keyboard accessible, with a reduced-motion version, in dark and light.

Magnet Toggle props

PropTypeDefaultDescription
labelstringRow label.
hintstringSecond line under the label.
checkedbooleanStart on.
onChange(on: boolean) => voidCalled when the value changes.
autoplaybooleanShowcase mode: flips by itself until touched.

Methods on the ref

Use it in React

import MagnetToggle from './MagnetToggle';

<MagnetToggle />

The Vue, HTML, Next.js, Tailwind and Motion versions take the same options.

More in Ferro

Good for: Micro-interactions.