Magnet

No dependencies
Code format

Install with shadcn

Needs a free account token. Get a token

npx shadcn@latest add @movin/tab-magnet

About this component

A frosted acrylic bar with a violet edge light. A soft highlight follows your pointer along the bar, and when you pick a tab the solid violet pill snaps in from exactly where the pointer was and settles on it.

Triggers

  • Click
  • State change
  • Hover
  • Mouse tracking
  • Spring

Techniques

  • Mouse tracking
  • Event position
  • CSS variables
  • Keyframes

Difficulty

Intermediate

Accessibility

Keyboard and screen readers

A WAI-ARIA tablist (aria-label "Billing period") of buttons with role="tab", aria-selected and aria-controls, a roving tabindex, Left and Right arrow keys plus Home and End, and one tabpanel per tab; :focus-visible outlines the tab. Every drawn part is aria-hidden.

Reduced motion

The transitions and loops are switched off, so the selection changes at once.

Use it in anything you build, commercial and client work included. Licence

More tabs

See all

ManilaGet code

MemphisGet code

MercuryGet code

NimbusGet code