🦄 mantine-scheme-transition 1.0.0: dark mode that starts where you click

Hey everyone 👋

A new extension joins the Mantine Extensions family today: mantine-scheme-transition 1.0.0.

A Mantine card titled Appearance halfway through a switch to light mode: a light circle spreads from the scheme toggle in the top right corner across the dark card, toward a sunset picture and a Change picture button.

What it does

Press the dark mode toggle and the new scheme spreads across the page from the button you pressed: a circle, a wipe, a curtain or a dissolve. It's built on the browser's View Transitions API, so the old and the new page are real snapshots, not a colour fade on every element.

import { SchemeToggle } from '/mantine-scheme-transition';

function Demo() {
  return <SchemeToggle transition="circle" />;
}

SchemeToggle takes ActionIcon's props (variant, color, radius), and its size is responsive. For a menu item, a hotkey or a SegmentedControl, the useColorSchemeTransition hook gives you toggle, setColorScheme and clearColorScheme with the same reveal.

The edges took longer than the animation

A keyboard press has no pointer, so the reveal starts from the toggle. prefers-reduced-motion gets an instant switch by default. forceColorScheme never starts a reveal. And browsers without view transitions just get Mantine's instant switch, no error.

The one that suprised me came up in review, before the release: three calls in the same tick (dark, light, dark) could end on light. My first fix waited on the pending update's promise, and it got one ordering right while breaking another.

A takeaway for your own code

When the browser already keeps a queue, use it instead of building your own next to it. The fix that held: a change with nothing to animate still goes through startViewTransition, and skips its own animation at once. The browser runs every update in call order, so the latest choice wins. I checked it in real Chromium and Firefox, not only in the tests.

I'd love your input

  • Would you use it in an app, or mostly on a docs site?

  • Which transition is missing? A diamond, blinds, something else?

  • Which extension should get some love next?

Drop a comment below, I read every one.

npm:
Docs:
GitHub:

2 views

Add a comment

Replies

Be the first to reply

Have a question or a thought to share? Add a comment above to start the conversation.