Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dark Theme for Ionic 4

Tags:

ionic4

In Ionic 3 I could easily apply a dark theme to my app by adding just one line to my variables.scss:

@import "ionic.theme.dark";

Is that still possible in Ionic 4 as simple as that? And if yes, how?

like image 578
Markus Avatar asked Oct 03 '18 15:10

Markus


People also ask

How do I enable dark mode in ionic?

Ionic Dark Theme​ Ionic has a recommended theme for variables to use in order to get a dark mode based on the device running the app. It can be broken down into the following parts: Changing the default Ionic colors for all modes to complement the dark background in the body. dark selector.

How do you change the theme in ion 4?

The fastest way to change the theme of your Ionic app is to set a new value for primary , since Ionic uses the primary color by default to style most components. Colors can be removed from the map if they aren't being used, but primary should not be removed.

Why is Ionic App dark?

You're probably supporting Dark Mode. Check Settings/Display & Brightness/Dark mode and see if it reflects in your app. My app just starting do this too.

How do I turn off dark mode in ionic 5?

One way to remove the dark theme would be by editing the variables. scss file and removing this style rule: @media (prefers-color-scheme: dark) { ... } That media query is the one that changes all the colors of the CSS custom properties when the users selects the dark theme on the device.


1 Answers

You have to make your own CSS variable. As an example

:root {
  .red-theme {
    // your colors --ion-color-primary etc
  }
}

and use RendererFactory2 for more info you can see on this link

like image 94
TehGaz7 Avatar answered Sep 19 '22 06:09

TehGaz7