×

Ionic Colors

Ionic Colors

Before we start with the actual elements available in the Ionic frame, let's understand a little bit how Ionic uses colors for different elements.

Ionic Color Classes

Ionic framework is a set of nine predefined color classes, which are used to change the color of many elements. You can use this to override it with your styling. Each color is a set of multiple properties, which include tint and shade, used throughout the ionic.

The color can be applied to an ion element to change the default colors using the color property. If there is no set of colors on the button, then by default, it uses the primary color.

The given below table shows the default sets of nine color provided by the ionic framework.

Class Name Color Description
Positive   It is used to be for blue color
Balanced   It is used to be for the green color
Assertive   It is used to be for the red color
Dark   It is used to be for black color
Energized   It is used to be for the yellow color
Light   It is used to be for white color
Royal   It is used to be for violet color
Stable   It is used to be for light grey color
Calm   It is used to be for light blue color

Ionic Color Usage

Ionic makes use of several classes for each component. For example, a button has a button class, and a header element has a bar class. Now, if you want to create a light blue button, you'll use the primary button class as follows.

My Collections

Like any other CSS class, we can also use the ionic color class. The given below code helps us to understand the use of the color property.


 Collection
 

When you execute the above code, it changes the collection button in the light blue color. The given below screenshot shows the output.

When you execute the above code

Adding colors

Colors can be added for use during an application by setting the color property in an ion component or design using CSS.

If you want to add a new color, firstly, define the CSS variables for all the changes of the color at the root. For example, to add a new color favorite, you can define the following variables:

CSS File

:root {
 --ion-color-favorite: #2059c9;
 --ion-color-favorite-rgb: 32, 89, 201;
 --ion-color-favorite-contrast: #0a0a0a;
 --ion-color-favorite-contrast-rgb: 10, 10, 10;
 --ion-color-favorite-shade: #6bb6db;
 --ion-color-favorite-tint: #75a8e6;
 } 

By using these CSS variables you can create a new class. The class must be written in the format of .ion-color-{COLOR} where {COLOR} is the name of the color which you want to add:

.ion-color-favorite {
 --ion-color-base: var(--ion-color-favorite);
 --ion-color-base-rgb: var(--ion-color-favorite-rgb);
 --ion-color-contrast: var(--ion-color-favorite-contrast);
 --ion-color-contrast-rgb: var(--ion-color-favorite-contrast-rgb);
 --ion-color-shade: var(--ion-color-favorite-shade);
 --ion-color-tint: var(--ion-color-favorite-tint);
 } 

After adding the class, the color can be used on any ion element that supports the color attribute. Below is an example of using the favorite color on the Ionic button.

Favorite

The given screenshot shows the output of the following Syntax.

screenshot shows the output of the following Syntax.

Related Topics

Ionic Colors

Ionic Colors Before we start with the actual elements available in the Ionic frame, let's understand a little bit how Ionic uses colors for different elements. Ionic Color Classes Ionic framework is a set of nine predefined...

3 minutes read.

Ionic Date Time

Ionic Date Time The DateTime component is used to display an interface that makes it simple for users to select dates and times. Tapping on <ion-datetime> will display a slider up from the...

4 minutes read.

Ionic Alert

Ionic Alert An Alert is a dialog box that presents the users with important information, or it stores the data from the user by using the inputs. Alerts are a great way to provide...

5 minutes read.

Ionic vs Apache Cordova

Ionic Vs Apache Cordova Ionic and Cordova are two popular technology going on in the market for mobile application development. The combination of these two technologies creates a development platform that is known as...

3 minutes read.

Ionic Tutorial for Beginners

What is Ionic? Ionic is an open-source framework that is used for the development of mobile applications. It is also used to build android applications, iOS, applications, desktop applications, and web applications using web...

4 minutes read.

Difference between Ionic 4 and Ionic 3

The ionic framework is an open-source platform that is used to develop mobile applications. It is also used to build android applications, desktop applications, iOS, and web applications using web technologies like HTML,...

5 minutes read.

Ionic List

Ionic List The ionic list is created of several rows of items that can contain text, buttons, thumbnails, keys, icons, and more. Lists are one of the essential components in any web or...

4 minutes read.

Ionic vs React Native

Ionic Vs React Native Ionic and React Native are both common framework which is used to develop mobile applications. Here, you will know about the popular differences between the ionic and the React Native. Ionic Ionic...

3 minutes read.

Ionic progress bar

The ionic progress bar element is a horizontal progress bar used to visualize the progression of operation and activity. You can use the <ion-progress-bar> component to create a progress bar in the ionic...

4 minutes read.

Ionic framework Installation

Installation of Ionic Before proceeding with the ionic application, you'll need to install node.js and NPM (Node Package Manager), the code editor, and Ionic CLI. Installation of node.js and NPM These are the primary...

5 minutes read.

Ionic Grid

The Ionic grid is a very powerful mobile-first flexbox system for building the custom layouts. It is a CSS feature supported by all devices that ionic supports. The Ionic grid is composed of...

11 minutes read.

Ionic Loading

The ionic loader is an overlay that can be used to indicate activity, the user interaction while blocking. The ionic loader shows on the top of the app content, and it can...

5 minutes read.

Ionic-fab Button

Ionic-fab Button The Ionic FABs (Floating Action Buttons) are standard material design compounds. It is a container element that contains one or more fab buttons. They are required to be placed in a fixed position,...

2 minutes read.

Ionic Geolocation

In today’s time, the mobile location plays an essential role in the mobile application. The Ionic Cordova geolocation plugin provides information about the location of the device, like as latitude and longitude. The...

5 minutes read.

Ionic Menu

The Ionic menu is the side-menu navigation that can be slide in from the side of the current view. By default, the menu slides in from the left side, but the side...

7 minutes read.

Ionic Navigation and Routing

The latest version (ionic 4) of the ionic framework, no longer limited to the angular. In Ionic 4, you can create an ionic project in different front-end frameworks such as Vue.js, React.js, and...

6 minutes read.

Ionic Checkbox

Ionic Checkbox Ionic Checkbox is nearly the same as a toggle. It can be placed in an ionic element or used as a separate checkbox. It is designed differently for every platform, such...

2 minutes read.

Ionic Reorder

The Ionic offers the <ion-reorder> component to reordering features. Ionic reorder component adds the Drag and Drop feature to list items, in which the user can change the order of the items. Reorder...

3 minutes read.

Ionic Camera

Hybrid mobile applications can make very quickly, but sometimes it becomes a challenge to get the features that access the hardware such as GPS, storage, file storage, cameras, and networks. Cordova offers plugins...

4 minutes read.

Ionic Toggle

The toggle is the same as the HTML checkbox entry, but it looks different and easier to use on a touchscreen device. It is an input component that holds the boolean value. Toggle...

2 minutes read.