Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alexwhitmore/simple-themes

Drop in dark mode in with theme preference and no flashes of unstyled content.
https://github.com/alexwhitmore/simple-themes

astro css dark-mode dark-theme html javascript themes

Last synced: 13 days ago
JSON representation

Drop in dark mode in with theme preference and no flashes of unstyled content.

Awesome Lists containing this project

README

        

# Simple Themes

Drop in dark mode with 2 lines of code with `prefers-color-scheme` and no flash of unstyled content (FOUC)!

> [!WARNING]
> This project is a WIP, and should not be used in a production environment yet.

## HTML Set up

CDN link to be used in your project

```html

```

index.html
```html








Toggle Theme

```

styles.css
```css
:root,
html[data-theme='light'] {
background-color: white;
color: black;
}

html[data-theme='dark'] {
background-color: black;
color: white;
}
```

## [Astro](https://github.com/withastro/astro) Set Up

src/pages/index.astro
```astro
---
import '../styles/globals.css'
---





Toggle Theme

```

src/styles/globals.css
```css
:root,
html[data-theme='light'] {
background-color: white;
color: black;
}

html[data-theme='dark'] {
background-color: black;
color: white;
}
```