-
Notifications
You must be signed in to change notification settings - Fork 17
Major changes: Add System Theme Mode, Color Preferences, Accessibility and more! #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…er dependency versions. Update failing build, tests.
…alf to mention moon
@JoseRFelix Hey mate, any chance of this getting merged? I know its a lot of changes. Thanks! |
I've been using this on my personal website (mobeigi.com) for some time now and it works very well. I'm not sure if the original author of this repo (@JoseRFelix) has any plans on merging this PR or maintaining it. I may otherwise fork it with these changes so I can pull in the library myself from a centralised package manager (because to date I've been using it as a local packed file which is not ideal). |
@JoseRFelix Can we please get this merged? |
Intro
Thanks for the great component @JoseRFelix ! I've been using it on all my projects and I really like the design and animations of this toggle. In particular, the fact its a single icon with no background clutter.
I have been making various edits to the component for my own needs and decided to contribute the changes back to the community. I am happy to take in feedback and make further changes to address any concerns.
Overview
This PR is huge and lots of changes have been made in one go.
2.0.0
(due to lots of breaking changes that are not backwards compatible)18
, Node20
, react-spring9.7.4
) (partially addresses Deprecated packages #45)demo.gif
Demo (Examples)
chrome_t7rjBv21yd.mp4
Changes
System ThemeMode
There is a new third state in the 'toggle' for the System (or Auto) mode!

The design chosen was a half sun and half moon. This design was choses as it looks good and is easily understood. It can also animate well with the other existing sun and moon designs.
Color customisation
One common issue with the component was it was hard to customise the colors easily beyond the now removed
sunColor
andmoonColor
.We now have the following optional
colors
props:This allows you to style each different theme mode however you like.
You can provide partial overrides or specify each color option.
If this prop is not provided, the default styling will be used.
API changes
There are breaking changes in the API that are not-backwards compatible.
Changes include:
ThemeMode
and not a booleanisSystemThemeModeEnabled
is new prop that can control if the system theme mode is being used or not (defaults totrue
)themeMode
is now the prop to bind (replaceschecked
)colors
provides more configurationisSystemThemeModeEnabled
This prop is new prop that can control if the system theme mode is being used or not (defaults to
true
).If this is set to false, it results in the classic 2-state dark/light mode toggle with same animations as before (except with the janky overshoot removed).
Theme switch direction
The theme switch direction is:
System
->Dark
->Light
I found this cycle path to look the best animation wise.
The choice was made NOT to allow this to be configurable because the animations depend on the ordering. Maybe this can be changed in future PR if there is a need for it.
Single Color Mode
If using single color scheme (i.e. black), the system design and light mode design are identical and not distinguishable.
My recommendation is to not support this (and encourage using fills and/or strokes to try and distinguish the system theme mode). This is solved if you instead use 2 colors (black/white).
Issues
High prio
Low prio
yarn start
in examples does not watch for changes in main package. Requires restart to detect changes.Manual tests
Test on all browsers
Pre-merge TODOs