Loading episodes…
0:00 0:00

Ionic 5 Content Padding Example

00:00
BACK TO HOME

Ionic 5 Content Padding Example

ahmed March 30, 2020 1 min read

In Ionic 5, there are some changes regarding how we set padding of the ion-content component.

We set the padding by using these CSS custom properties:

  • --padding-bottom Bottom padding of the content

  • --padding-end Right padding if direction is left-to-right, and left padding if direction is right-to-left of the content

  • --padding-start Left padding if direction is left-to-right, and right padding if direction is right-to-left of the content

  • --padding-top Top padding of the content

For example, in the SCSS file associated with your component, you need to add:

ion-content {
  --padding-bottom: 10px;
  --padding-end: 10px;
  --padding-start: 20px;
  --padding-top: 20px;
}

This should add padding inside the content area.

You need to replace the attributes Ionic 4 to CSS classes in Ionic 5. For example:

<ion-header text-center></ion-header>
<ion-content padding></ion-content>

Becomes:

<ion-header class="ion-text-center"></ion-header>
<ion-content class="ion-padding"></ion-content>

Or also

<ion-content color="primary" padding></ion-content>

Becomes:

<ion-content color="primary" class="ion-padding"></ion-content>

Join the 10xdev Community

Subscribe and get 8+ free PDFs that contain detailed roadmaps with recommended learning periods for each programming language or field, along with links to free resources such as books, YouTube tutorials, and courses with certificates.

Audio Interrupted

We lost the audio stream. Retry with shorter sentences?