Astro Eclipse
Astro integration

Change the theme. Watch it happen.

Astro Eclipse switches themes with a View Transition that starts where the visitor clicked. No flash on load, no broken state across ClientRouter navigation, plain CSS for the palettes.

Try it here

Pick a theme. The reveal starts at the button you press. Choose system to follow your OS and see it change live.

Applied: … / Preference: …

What you get

  • No flash

    A tiny inline script in the head sets the theme attribute before first paint, from storage or from the system setting.

  • Survives navigation

    The theme is re-applied to the incoming document on every ClientRouter swap, so pages never blink back to the default.

  • Respects the visitor

    Reduced motion, a missing View Transitions API and an unknown effect all fall back to an instant switch.

Install

npm install astro-eclipse

Add the integration to astro.config.mjs and list your theme names.

import eclipse from 'astro-eclipse'

export default defineConfig({
  integrations: [
    eclipse({
      themes: ['light', 'dark', 'sepia', 'forest'],
      default: 'system',
    }),
  ],
})

Then call the client API from any script.

import { toggleTheme } from 'astro-eclipse/client'

button.addEventListener('click', (event) => {
  toggleTheme({ origin: event })
})