How to change the application theme in Ionic 4

Asked

Viewed 386 times

0

I’m using Ionic 4 and I’m having a hard time changing the theme to dark.

In Ionic 3, I was only in the document scss variables. and made the change:

de
@import "ionic.theme.default"; 
para
@import "ionic.theme.dark";

Now, when I enter the document scss variables. no longer has the import of "Ionic.Theme". How do I change the theme of my application in Ionic 4?

1 answer

1


It works with componentization, example:

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.dark.scss'],
})

If you use Materials:

function changeTheme(themeName) {
  document.getElementById('themeAsset').href = `/path/to/my/${themeName}.css`;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.