Integrates dark mode into gatsby-theme-try-ghost. This theme makes use of latent-component-shadowing and showcases best practices for adding custom themes to
yarn add gatsby-theme-ghost-dark-mode
This theme is an add-on theme designed to seamlessly integrate with gatsby-theme-try-ghost. The theme uses functions provided by
gatsby-theme-try-ghost, so installing
gatsby-theme-try-ghost is required.
yarn add gatsby-theme-try-ghost
How to use
// In your gatsby-config.js
// Set to true if you want your theme to default to dark mode (default: false)
// Note that this setting has an effect only, if
// 1. The user has not changed the dark mode
// 2. Dark mode is not reported from OS
// If you want the defaultModeDark setting to take precedence
// over the mode reported from OS, set this to true (default: false)
// Note that user choice still takes precedence over this setting
This Gatsby theme plugin hooks into the
gatsby-theme-try-ghost theme and adds a dark mode toggle in the top right navigation bar. User's dark mode settings are persisted to
localStore, so they should remain on page revisits. If the functionality is provided by the browser, dark mode setting is read from the OS and that setting is taken for first time use. The
defaultModeDark setting is taken, if OS does not report dark mode or if the user has not chosen a theme preference in the OS. Finally, OS settings can be overruled with
This plugin also shows how to best customize
gatsby-theme-try-ghost. The latent-component-shadowing approach used here is very general and is an amazing concept. This is useful if you plan on customizing
If you use PrismJS your prism styles might be changed. Currently, the best option is to use a dark PrismJS style that looks great in both dark and light mode.
PRs are welcome! Consider contributing to this project if you are missing feature that is also useful for others. Explore this guide, to get some more ideas.
Copyright & License
Copyright (c) 2020 styxlab - Released under the MIT license.