Perfect dark mode for Astro in few lines of code. Theme Toggle for Dark, Light & Auto (system)
npm install astro-color-schemeAstro Color Scheme is a fully headless dark mode theme toggle for Astro.
Live Demo on Stablo Template →
```
npm install astro-color-schemeor
pnpm add astro-color-scheme
You can toggle the theme using button, select, checkbox or radio inside the .
`jsx
---
import { ThemeSwitch } from "astro-color-scheme";
---
Advanced Examples
Using Select:
`jsx
---
import { ThemeSwitch } from "astro-color-scheme";
---
`Using Radio:
`jsx
---
import { ThemeSwitch } from "astro-color-scheme";
---
`
Set theme without any toggle
`jsx
---
import { ThemeSwitch } from "astro-color-scheme";
---
`Options
Options for
ThemeSwitch| option | required | notes |
| -------------- | ---------------------------- | --------------------------------------------------------------- |
|
strategy | required if you use toggle | Possible values: button, checkbox, select or radio |
| defaultTheme | optional | Default: system, Possible values: light, dark or system |
| as | optional | Default: span, Possible values: div, span |The
as option lets you select what wrapper element to use for the ThemeSwitch. Elements Allowed for Toggle inside ThemeSwitch are