Skip to content
nuxt-penumbra
Esc
↑↓navigate↵open⌘Jpreview
On this page

Prior art

What already exists for theme switching and for view transitions in Nuxt, and where nuxt-penumbra fits.

nuxt-penumbra does not replace any of these. In most cases it sits on top of one.

@nuxtjs/color-mode

@nuxtjs/color-mode is the standard way to handle dark and light mode in Nuxt: it stores the preference, resolves system, and sets a class on <html> before first paint. It has no animation. nuxt-penumbra uses it as the store and adds the transition on top, without storing anything itself.

Nuxt UI color mode components

UColorModeButton, UColorModeSwitch and UColorModeSelect change the theme through color-mode. They switch instantly. nuxt-penumbra animates their writes with no wrapper. See Nuxt UI.

Nuxt’s experimental viewTransition

Nuxt has an experimental.viewTransition option that runs page navigations inside a view transition. It is about routes, not themes. The two can be on together: nuxt-penumbra skips its own transition while a navigation runs, so they do not cancel each other.

css-theme-transition

css-theme-transition is a package for theme-switch animations on View Transitions, aimed at React and Next.js. It has no Nuxt integration or color-mode awareness.

@space-man/react-theme-animation

@space-man/react-theme-animation does theme switching with view transition animations and multiple themes, for React. The idea is the same as here; the framework is different.

Hand-written CSS

You can write the effect yourself. The usual recipe is document.startViewTransition(() => toggle()) plus CSS on ::view-transition-old(root) and ::view-transition-new(root):

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

It works, and for one effect it may be all you need. What nuxt-penumbra adds is the origin handling, the effect library, the guards (reduced motion, no API, navigation, a second toggle during a transition), the replay of writes that come from Nuxt UI’s components, and the no-flash head script in standalone mode. If you need only a fade, the hand-written version is a few lines.

astro-eclipse

The Astro integration by the same author runs the same engine. See using Astro.

Was this page helpful?