Theming
Learn how to style the template with the styles of your app.
Last updated
Was this helpful?
Learn how to style the template with the styles of your app.
Last updated
Was this helpful?
The template includes lots of pages, features and components but you are free to use just what you need and delete the code you don't. The code structure is super modularized so you will find easy to modify the code to fit your needs.
To learn more about theming an Ionic 5 app please go to
So, for example if you want to change the colors of your app, by just changing some variables your app will have the desired colors in just a few seconds!
All of the Ionic components are themed using . CSS variables make possible to change CSS dynamically at runtime (which previously required a CSS preprocessor). CSS variables make it easier than ever to override Ionic components to match a brand or theme.
.
In the file src/theme/variables.scss
you will find all the color variables we used in to style this template. You can change them and see how to app changes the colors.
You can use the to create a custom color palette for your app’s UI and then update the values in src/theme/variables.scss.
In the file src/theme/variables.scss
you can set the font family of the entire app.
To add new colors we used the filesrc/theme/custom-colors.scss
where we define colors for buttons for example. If you want to create specific colors different from the theme colors, you should put them here.
Ionic provides platform specific styles based on the device the application is running on. Styling the components to match the device guidelines allows the application to be written once but look and feel native to the user depending on where it is accessed.
In some of the pages of this template we added some platform specific styles. For the sake of simplicity, in this cases, we created a separate stylesheet for each platform for each component.
Let's see the screenshot below, user-profile.page.ios.scss
has some specific styles for iOS for the user profile page.
Each component has its dedicated sass files well structured with independent variables so you can have maximum modularity, flexibility and customizability.
For this Ionic app we created a few custom mixins to ease the styling of some components.
You can find them under src/theme/mixins/inputs
The inputs.scss
file imports all the mixins so when you want to use one of them from your scss file, you just need to import inputs.scss
Each mixin defines some css4 variables. Each time you include a mixin into your styles, you can set the value for these variables.
Let's see an example with the Select Alert. The following code is for the definition of the mixin:
Now, when we want to use the select alert mixin we need to include it as the following code:
Note that in the above code we set the values of the mixin variables to style this particular alert component.
We have the following mixins available for you to use. Let's go through each of them so you can understand how to use them.
This mixin is used to create the tags selectors from the Filters page. Both the square and rounded tags are styled using this mixin.
The color-radio
mixin is used to style the color chooser component from the Filters page.
To learn how to use the Color Radio custom component go to:
Of course you can change the use of this component for your personal use case by just changing the content of the tags.
Because alerts and in general all overlays are attached to the body or ion-app
directly, we need to use ::ng-deep
to access it from other pages such as FashionDetailsPage.
So, from src/app/fashion/details/fashion-details.page.scss
, we include the select-alert()
mixin, and we set the value for the mixin variables.
This project uses , which basically is CSS with superpowers.
A Mixin is a block of code that lets us group CSS declarations we may reuse throughout our site. You can learn more in
We use if from the src/app/forms/filters/forms-filters.page.scss
and basically it help us transforming a traditional into this beautiful color chooser component.
In the filters page we also have this budget selector which has the functionality of a
We created this mixin to ease the job of styling an .