×

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 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 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 Modal

Ionic modal is displayed as a temporary UI that slides into the screen. The ionic modal is a dialog box that is displayed at the top of the app’s content, and it...

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 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 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 Buttons

Ionic Buttons There are different types of buttons in the Ionic framework. These buttons are subtly animated, enhancing the user experience when using the application. Buttons are a fundamental way of interacting and navigating...

4 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 Infinite Scroll

The infinite scroll permits you to perform an action when the user scrolls a particular content from the bottom or top of the page. When you display the large collection of data...

3 minutes read.

Ionic Select

The Ion Selection component is similar to the HTML <select> element. However, the Ionic Selection component makes it easy for users to categorize and choose the preferred option or other options. You must...

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.

Ionic Refresher

Refresher means updating the currently showing page so that the user can see the latest view. It is also known as re-loading in web technology. It provides a pull- to-refresh feature on a...

4 minutes read.

Ionic Actionsheet

Ionic Actionsheet The Action sheet is a dialog box that displays a group of options. It is shown on the top of the application content and must be dismissed manually before the user can resume...

3 minutes read.

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 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.

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 vs PhoneGap

Ionic Vs PhoneGap Ionic and PhoneGap are both used to develop the mobile application. Both Frameworks are used in large enterprises by the developers. Here, we are going to compare the important differences between ionic...

3 minutes read.

Ionic Segment

A segment is a collection of buttons, sometimes which are known as segmented controls. The segment buttons are displayed at horizontal rows. These segment buttons can be shown in a toolbar or the...

2 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 Tabs

The ionic tabs mostly used for mobile navigation. It means that tabs are placed at the top of the display on android devices, while at the bottom on IOS. It does not provide...

2 minutes read.