×

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 Popover

The Ionic popover is a small dialog box that displays at the top of the screen. It can be used for anything, but it is usually used for a button, an action,...

4 minutes read.

Ionic Radio

Ionic Radio The radio button is the type of input component that has a Boolean value. The Ionic radio button has a different pattern on every platform, as well as other Ionic components....

2 minutes read.

Ionic Range

The Range slider lets users choose from a range of values by moving the slider knob. You can accept two knobs, but by default, one-knob controls the range value. Range labels You can put down on...

2 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 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 vs Xamarin

Ionic vs Xamarin Ionic and Xamarin are both the most popular frameworks used to develop a hybrid mobile application. Both frameworks are used in large enterprises by the developers. Here, we will discuss the...

4 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 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 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 Contents

Ionic Contents The content component provides an easy-to-use content area with some useful ways to control the scrollable region. There should be only one content in one view. Content, along with several other Ionic...

2 minutes read.

History of Ionic

It is a complete open-source platform for hybrid mobile application development created by Ben Sperry, Max Lynch, and Adam Bradley of Drifty Co. in 2013. The first alpha version of the framework was...

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

A toolbar is a general toolbar that can be used in an application such as a header, sub-header, footer, or even a sub-footer. Because the ion-toolbar is flexbox-dependent, no matter how many toolbars...

3 minutes read.

Ionic Slides

The ionic slides component is the multi-section container. You can swipe or drag any segment between them. This contains any number of slides components. Slides help it easy to make galleries, tutorials, and...

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