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

https://github.com/moderrek/vanilla-theme

An example of how to create light and dark mode for vanilla HTML
https://github.com/moderrek/vanilla-theme

css dark dark-theme frontend html javascript js light mode persistent-storage theme theme-switcher ui vanilla-javascript

Last synced: 4 months ago
JSON representation

An example of how to create light and dark mode for vanilla HTML

Awesome Lists containing this project

README

          

# ๐ŸŽจ Vanilla Theme

![License](https://img.shields.io/github/license/Moderrek/vanilla-theme)
![Issues](https://img.shields.io/github/issues/Moderrek/vanilla-theme)
![Forks](https://img.shields.io/github/forks/Moderrek/vanilla-theme)
![Stars](https://img.shields.io/github/stars/Moderrek/vanilla-theme)

This repo provides a simple **example** of a themes implmented using **pure vanilla** HTML, JS and CSS.
It demonstrates how to create themes and a theme switches that respects the user's
system preference and saves their choice for future visits.

![image](https://github.com/user-attachments/assets/9b5c158e-3d4c-46d7-9a9f-3b7f6ea1f07c)
![image](https://github.com/user-attachments/assets/2b64203d-6d14-4a96-99a4-3d65f7249ad2)
![image](https://github.com/user-attachments/assets/440adaca-394a-4500-8db8-7bc6ebcdf671)

## ๐Ÿ—บ๏ธ Overview

The example showcases:
- ๐Ÿ”Ž **Automatic theme detection**: Automatically applies the system's preferred color scheme. (light or dark mode)
- โš™๏ธ **Theme toggle**: Allows users to manually switch between light and dark themes.
- ๐Ÿ’พ **Persistent user preference**: Saves the user's theme choice using local storage, so their preference is preserved across page reloads.
- ๐Ÿ‘€ **Listens to the theme system**: If the system theme changes, the theme will be automatically changed on the website.

## ๐Ÿ“‚ Files Included

1. **`index.html`**: Basic HTML structure with a theme toggle button.
2. **`style.css`**: Example CSS with styling for LIGHT and DARK modes.
3. **`script.js`**: JavaScript to handle theme switching, system theme and persistent storage.

## ๐Ÿ’ป Usage

1. **Clone the repository**
```sh
git clone https://github.com/Moderrek/vanilla-theme
```
2. **Enter the project directory**
```sh
cd vanilla-theme
```
3. **Open `index.html` in your browser**
4. **Explore files and learn.**

# ๐Ÿค Contribution

Feel free to fork the repository and modify the example as needed for your own projects. If you have any improvements or suggestions, please submit a pull request.

# ยฉ LICENSE

```license
MIT License

Copyright (c) 2024 Tymon Woลบniak

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```