What?
Updated blog-starter example to support dark theme. Also added a button
to switch modes (User preference).
→ User can opt for dark / light / system mode
→ Mode is persisted using localStorage
→ Mode is also synced across browsing contexts
→ No FOUC (Flash of Unstyled Content)
→ Full SSG
→ No additional dependency
Why?
Now that dark mode is a first-class feature of many operating systems,
it’s becoming more and more common to design a dark version of your
website to go along with the default design.
How?
- Used tailwind `dark:` modifier
- Used localStorage for persisting user's preference
- Used storage event to sync the mode across tabs/iframes
- Injected script to avoid FOUC
- Added appropriate comments in the code for clarity and readability
### What?
This updates the `blog-starter` example to Next 14.1 App Router.
### Why?
I checked out a new `blog-starter` project on Vercel and was surprised
it was using the Pages Router. I believe the App Router is a better
choice.
### How?
I tried to keep the implementation logic as close to the original Pages
`blog-starter`.
---------
Co-authored-by: Sam Ko <sam@vercel.com>
2024-01-30 17:16:55 +00:00
Renamed from examples/blog-starter/tailwind.config.js (Browse further)