×

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

The ionic spinner component provides the various SVG (Scalable Vector Graphic) spinners. Ionic spinners are the visual indicators that display the app which is loading content or performing another process that the user...

5 minutes read.

Ionic Chip

Ionic chip displays the complex entities in small entities in small blocks, such as the contacts. Ionic chip has several types of elements like avatars, thumbnails, text, and icons. It is a bubble-like...

3 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 Editors

Editors are software programs that permit the users to create and edit the text files. In the development field, editors are usually used to create the source code editors that includes many specific...

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

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

Ionic Cards: Ionic cards are a standard part of the user interface that acts as an entry point for more specific information. These are the best components for displaying information...

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