Circular Reveal
View codeA radial clip-path expands from the click origin, sweeping the updated appearance into view.
Lightweight, CSS-first transitions powered by the View Transitions API. Try the demos below — each interaction reveals a different animation technique.
View on GitHubA radial clip-path expands from the click origin, sweeping the updated appearance into view.
The updated appearance sweeps in from the chosen edge.
The current appearance drops off the bottom edge; the updated appearance is visible underneath right away.
The current appearance turns away like a book page, revealing the updated appearance underneath.
Add the package to your project. It ships the animation helpers and companion CSS for the View Transitions API.
npm install @maxigarcia/view-transitions Call onCircularRevealAnimation with a callback that toggles the `dark` class. Pass the click event so a radial clip-path expands from the pointer and reveals the updated appearance.
@import '@maxigarcia/view-transitions/circular-reveal.css'; import { onCircularRevealAnimation } from '@maxigarcia/view-transitions';
button.addEventListener('click', (event) => {
onCircularRevealAnimation(
() => document.documentElement.classList.toggle('dark'),
event,
);
}); Call onSweepRevealAnimation with a callback that toggles the `dark` class. Pick a sweep direction so the updated appearance slides in from an edge or corner.
@import '@maxigarcia/view-transitions/sweep-reveal.css'; import { onSweepRevealAnimation } from '@maxigarcia/view-transitions';
button.addEventListener('click', () => {
onSweepRevealAnimation(
() => document.documentElement.classList.toggle('dark'),
'up',
);
}); Call onFallAnimation with a callback that toggles the `dark` class. The previous appearance drops off the bottom edge while the updated appearance appears underneath.
@import '@maxigarcia/view-transitions/fall.css'; import { onFallAnimation } from '@maxigarcia/view-transitions';
button.addEventListener('click', () => {
onFallAnimation(() => document.documentElement.classList.toggle('dark'));
}); Call onPageTurnAnimation with a callback that toggles the `dark` class. The previous appearance turns away like a book page, revealing the updated appearance underneath.
@import '@maxigarcia/view-transitions/page-turn.css'; import { onPageTurnAnimation } from '@maxigarcia/view-transitions';
button.addEventListener('click', () => {
onPageTurnAnimation(() => window.history.pushState(null, '', '/#page-1'));
});