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
- Host: GitHub
- URL: https://github.com/moderrek/vanilla-theme
- Owner: Moderrek
- License: mit
- Created: 2024-07-30T20:50:47.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-30T21:52:31.000Z (almost 2 years ago)
- Last Synced: 2025-06-12T17:50:02.551Z (12 months ago)
- Topics: css, dark, dark-theme, frontend, html, javascript, js, light, mode, persistent-storage, theme, theme-switcher, ui, vanilla-javascript
- Language: CSS
- Homepage: https://moderrek.github.io/vanilla-theme/
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐จ 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.



## ๐บ๏ธ 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.
```