Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic 5 forcing light theme for the browser app

i have built this app https://cvirus.app and build and deployed on browser.

on chrome browser on android phones it renders dark background (as dark theme is being applied by default it seems).

I want to force light theme everywhere no matter what device what browser. how do I do that?

commenting dark colors portins in theme/variables.scss did not work

like image 844
Moblize IT Avatar asked Mar 22 '20 20:03

Moblize IT


3 Answers

Since version 79 of the Chrome browser, you can choose between CSS prefers-color-sheme media feature values. Ionic respects this media feature and reacts to changes to it.

To change it without changing your OS preference and color theme, you need to open the Rendering panel in the Chrome Dev Tools:

  1. Open the the Chrome Dev Tools.
  2. Press Crtl+Shift+P on PC or Cmd+Shift+P on Mac.
  3. Type "Show rendering" in the Command Palette.
  4. Press Enter with the option Drawer | Show rendering selected, which should be already selected.

The Rendering drawer opens. Then on the "Emulate CSS media..." option, select the color scheme you prefer.

Print-screen of the actual option

like image 198
Dade Avatar answered Oct 27 '22 14:10

Dade


To resolve this, you have to go to theme/variable.scss at the src folder and locate

@media (prefers-color-scheme: dark)

And change from dark to light. If you have not modified the variable.scss. it should be in line 79. Click to see the screenshot of my own code I hope this helps.

like image 35
Ikenna Avatar answered Oct 27 '22 15:10

Ikenna


you should comment ios body and md body classes at the theme/variables.scss then it will become light mode. enter image description here

like image 27
erdemgunenc Avatar answered Oct 27 '22 16:10

erdemgunenc