ionic
  1. ionic-colors

Ionic Colors

Ionic provides a range of predefined colors that can be used in your app for backgrounds, text, borders, etc. These colors are defined in the CSS variables, and you can easily apply them to your app using the provided classes.

Syntax

To use the Ionic colors, you need to apply the corresponding class to the element. The classes are named using the format ion-color-{colorName}, where colorName is the name of the color you want to use.

<!-- Apply a background color -->
<div class="ion-color-primary"></div>

<!-- Apply a text color -->
<span class="ion-color-secondary">Text in secondary color</span>

<!-- Apply a border color -->
<div class="ion-color-tertiary" style="border: 1px solid;"></div>

Example

Here's an example of how you can use the Ionic colors to style your app:

<ion-header>
  <ion-toolbar color="primary">
    <ion-title>
      My App
    </ion-title>
  </ion-toolbar>
</ion-header>

<ion-content>
  <p class="ion-color-secondary">
    This is the secondary text color
  </p>

  <button class="ion-button ion-color-warning">
    Click me
  </button>

  <div class="ion-color-tertiary" style="padding: 10px;">
    This is the tertiary color background
  </div>
</ion-content>

Output

The above example will output a header with a blue background color, a paragraph with a gray text color, a button with a yellow background color, and a div with a dark blue background color.

Explanation

Ionic provides a range of predefined colors that can be used in your app. These colors can be easily applied to your elements using the corresponding class. The class name is constructed using the format ion-color-{colorName}, where colorName is the name of the color you want to use.

Use

You can use the Ionic colors to style your text, background, borders, and other elements in your app.

Important Points

  • The Ionic colors are defined in the CSS variables.
  • To use the Ionic colors, you need to apply the corresponding class to the element.
  • The class names are constructed using the format ion-color-{colorName}, where colorName is the name of the color you want to use.
  • You can use the Ionic colors to style your text, background, borders, and other elements in your app.

Summary

Ionic provides a range of predefined colors that can be easily applied to your app using the corresponding class. The class names are constructed using the format ion-color-{colorName}, where colorName is the name of the color you want to use. You can use the Ionic colors to style your text, background, borders, and other elements in your app.

Published on: