How to remove the padding around ion-item?

Aditya picture Aditya · Mar 30, 2018 · Viewed 28.3k times · Source

I want to remove padding from my ion-item so that it can occupy the full width of the page.

Please look in the dev tools to see the padding around the ion-item.

The ion-item has a padding of 16px, when I inspect the ion-item and also on the class="scroll-content" there I found scss in the inspector with

ion-app.md [padding] .scroll-content {
    padding: 16px;
}

If I remove this padding then ion-item can occupy the whole width by removing this padding, but When I use this in my scss file the padding is not removed.

Answer

massi picture massi · May 12, 2019

For those who are using ionic 4, you should use Ionic CSS Utilties for padding

In short, you have to code this:

<ion-item class="ion-no-padding">
  <ion-thumbnail>
    <img class="imgmg" src="...">
  </ion-thumbnail> 
  <h2>Text</h2>
</ion-item>

If you want to remove inner paddding, use ion-item custom CSS properties:

ion-item {
  --padding-end: 0px;
  --inner-padding-end: 0px;
  // here other custom CSS from documentation
}