-
Notifications
You must be signed in to change notification settings - Fork 13.5k
feat: Dark theme #18713
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
Comments
Hi there, Ionic does ship with a "dark" color palette. For most components, you can do Thanks! |
We don't have plans to add a dark theme at the moment, but it is something that could easily be done in the starters. We have a dark theme added in the conference app, and plans to include a "toggle" to switch between light and dark theme there. It wouldn't be too much more to have it added to the starters. |
@liamdebeasi This is more about application wide dark mode. Similar to what @mhartington described here: https://ionicframework.com/blog/hot-take-dark-mode/ @brandyscarney A lot more needs to be done to make it truly complete. Like we also need to swap the 'dark' and 'light' colors or just use a different set of colors for all colors including primary, secondary etc... to match whatever colors iOS13 and Android10 are defaulting to in their native dark themes. There are issues with borders of some controls like toggles as described above, and also with borders and background colors of alerts, popovers, action-sheets when trying to make everything dark. Currently they just 'blend' in too much with the content dark background - almost invisible. Having a toggle in the sidebar to let user switch between light and dark themes will be great. Bulk of the users are not going to be on the latest OS release for a long time, and some may want to change settings per app. A lot of it can be implemented at the application level and we have been trying to implement this by modifying the theme/variables.scss. But not everything can be fixed there. Moreover it seems like something that will help all Ionic applications. |
@sachingarg05 Why would we swap the dark and light colors? You may still have use for a light color or a dark color on a dark theme. You can override the colors though if desired, it would look like the following:
These colors are meant to be customized, but they don't match either iOS or Android by default. The primary color is the Ionic blue.
If there are any specific issues with dark theme variables not working to override specific components we can fix it but we need to have issues reported to track this. I recently fixed this issue regarding the overlay background color: #18658 Here's how I see our dark theme in MD mode: I don't see it blending here, but if there are specific cases where it does we can look into it. The way the defaults for dark theme work is by looking at the default light color. For example, alert's background uses The closest is step 50, so we use the
These can be manipulated to use lighter or darker colors or have more variation, or you can use our generator here that uses the same formula as we do for the light colors: https://ionicframework.com/docs/theming/advanced#generate-stepped-color-variables |
Thanks, I understand this better now. Looks like some of our issues can be resolved by fixing our --ion-color-step values. We had just copied the step values from someone's sample code and the step-50 was less than our chosen background gray. Will report any specific issues that we can't resolve using variables.scss and step colors. I do feel that the variables.scss in "Ionic start" templates should include a dark theme section, even if its commented out by default. For toggle shadow color, can this be fixed by us in our application - in variables.scss or a parameter when creating the toggle? Or do you plan to change the shadows for toggle (and other components) to use one of the step color values? |
By swapping the dark and light colors, I meant that in light theme - light is the low-contrast color (closest to background color) and dark is the high-contrast color (opposite of background color). If we only change background color to dark, then a light becomes the high contrast color and dark becomes the low contrast color. So in our apps in dark theme, we would want light buttons to look 'dark' and the dark buttons to look light. To maintain same contrast effect as they did in light theme. I understand that we can fix this in our app by changing the colors in media-query in theme/variables.scss. |
Ah, okay! Yeah, if the stepped colors aren't set to a gradient going from the background -> text color it will look off by default.
I agree with this, but I'd like to work through fixing some of the bugs and making sure all of the defaults are good before we add it so that it doesn't need several iterations.
I believe it would need to be updated in Ionic. The box-shadow uses a value of:
So it needs to be something like:
This would make the box shadow use the RGB text color variable by default with a fallback of
This makes sense. I'm not sure if it should be something we provide by default but I can definitely see the use case for it. |
I started on some fixes here: #18735 Here's a preview: |
@brandyscarney So based on your answer we do need to reverse our steps if we switch to a dark theme? Or is it better to make our light to dark and our dark to light? What is considered best practice here? |
After talking with our designer, we decided we would be switching the
This can be generated for you in the documentation though, here: https://ionicframework.com/docs/theming/themes#stepped-color-generator We're currently working on the dark theme. Our designer provided some new Ionic colors and I have been tweaking some of the bugs in the components as I've found them in this PR here: #18735 Here's the latest design: Using the following variables:
This is not finalized, but when it is we will add it to the conference app and once we're satisfied with it we will add it to the starters as a toggle. |
A few observations, all for the iOS theme (MD theme looks OK):
Not sure if these need attention, maybe its OK the way it is:
Thanks a lot for all the effort you are putting into this. |
I fixed the checkmark, but the toggle is due to us having to match light mode first. We can use an Ours uses
|
Here's a dev release of the fixes from #18735 if you'd like to try it out: in Core
in Angular:
|
@brandyscarney what is generating those screenshots that you are posting showing the different themes? Is this just a demo app or something else? This would be SUPER useful for us when theming apps for different projects if it's something we can get access to. Thanks!! |
@ghenry22 It's one of our e2e tests, here: https://github.com/ionic-team/ionic/tree/master/core/src/themes/test/css-variables |
Awesome thanks! |
Really nice design 👍 |
I started messing around with ideas for how we can provide the official dark theme to the developers. There are a few different ways we could add this.
Let me know if anyone has ideas I'm missing! |
IMO this could just be put into the documentation with the other generator stuff: https://ionicframework.com/docs/theming/color-generator Top option could be light vs dark. This way you're not adding bloat to the framework and it all still fits with convention. I would definitely use this and would have found it in the documentation without any issues. |
Thanks for the feedback @CitizenBeta! I agree, I think it would be easier maintenance to have a docs page devoted to theming in dark mode and maybe some demos to show it off. I put together this Codepen on our official Ionic account: https://codepen.io/ionic/pen/zYOpQLj |
I created a new guide for dark mode in the docs in this PR: ionic-team/ionic-docs#940 Here is the main file in a README format: https://github.com/ionic-team/ionic-docs/blob/3e76eac99772bb2921b33912a04d9e1290688225/src/pages/theming/dark-mode.md Please let me know any feedback of how this can be improved, anything missing, and anything else. Thank you! |
Added a guide on dark mode here: https://ionicframework.com/docs/theming/dark-mode Please let us know if you have any feedback for docs improvement on this repo: https://github.com/ionic-team/ionic-docs Thank you!! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Doing dark theme right is hard, especially the details. For example, the ‘toggle’ border when disabled. Similar issues with alerts, popovers etc…
Changing themes and colors is now much easier in Ionic4 and we have seen some really good samples and examples posted by other developers and even Ionic team members with dark themes, and toggling between dark and light themes. We have tried to combine some of these into our apps to get a dark theme, but it is hard to get all the details right.
Are there any plans for default dark theme colors in Ionic? Now that the OS has its own dark theme, it will be even better to pick the same iOS/Android default dark colors instead using just another shade of gray.
The text was updated successfully, but these errors were encountered: