question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Can't modify spacing of ion-item

See original GitHub issue

Bug Report

Ionic version: [x] 4.7.

Current behavior: I am simply trying to reduce the spacing of the items in this ion-list: list Spent far too many hours reading tutorials on shadow dom and trying various variables. Nothing has worked (although i am able to make it bigger).

Google has returned numerous posts with people complaining about the same issue; with no solutions. After this much time i have to assume this is a bug.

And if not a bug… certainly far too difficult to make this simple modification.

I can likely accomplish what i am trying to do by not using an ion-list and just using std html components; but it is so close and easy to get this close - it seems hard to believe it can’t be tweaked a few pixels.

Expected behavior: the same list with slightly smaller spacing

Steps to reproduce:

Related code:

  <ion-list class="sidemenu-header-list" inset=true lines="none">
       <ion-item color="secondary">
         <h2>{{name}}</h2>
       </ion-item>

       <ion-item color="secondary" class="ion-no-padding" *ngIf="school">
         <ion-label style="font-size: 14px" text-wrap innerHTML={{school}}></ion-label>
         <ion-icon size="small" name="school" slot="start"></ion-icon>
       </ion-item>
       <ion-item color="secondary" class="ion-no-padding"*ngIf="year">
         <ion-label style="font-size: 14px" >{{year}}</ion-label>
         <ion-icon size="small" name="calendar" slot="start"></ion-icon>
       </ion-item>

     </ion-list>

Ionic info:

Ionic:

   Ionic CLI                     : 5.2.5 (C:\Users\Peter\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.7.4
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Capacitor:

   Capacitor CLI   : 1.0.0-beta.24
   @capacitor/core : 1.0.0-beta.24

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 8 other plugins)

Utility:

   cordova-res : 0.3.0
   native-run  : 0.2.8

System:

   Android SDK Tools : 26.1.1 (C:\android-sdk)
   NodeJS            : v10.13.0 (D:\Program Files\nodejs\node.exe)
   npm               : 6.11.3
   OS                : Windows 7

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
liquidcmscommented, Oct 21, 2019

Hi Brandy, thanks as always… that does the (painful) trick. Your suggestion reduces overall line height to 33px (from 48) - which is the size of the icon.

test2

i’ll need to tweak a little to center icon with text and prevent text from getting clipped - but this has fixed my issue.

Thank you and sorry for reporting this as a bug.

And thanks Liam for looking at this. I had most of a demo repo put together when Brandy posted.

1reaction
liamdebeasicommented, Oct 21, 2019

Thanks for the issue. These components are designed to match the iOS/MD spec by default so it’s likely you will need to customize some of the margin/padding yourself. You should be able to adjust the margins on ion-label and possibly the padding on ion-icon.

Can you try that and let me know if it resolves your issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: Can't modify spacing of ion-item · Issue #19702 - GitHub
Ionic version: [x] 4.7. Current behavior: I am simply trying to reduce the spacing of the items in this ion-list:
Read more >
How to remove the padding around ion-item? - Stack Overflow
try to add an id = 'ion-overrides' or whatever you want to call it to your body element and then in your scss...
Read more >
Extra space appear in ion-item after changing language
I'm using ion-label with position=“floating”. I believe that position floating is causing this issue but i need to know how can I fix...
Read more >
CSS Utilities: Classes for Text/Element Alignment or Modification
Ionic CSS utility classes can be used on any element for text modification/alignment, element placement, or to adjust padding and margin.
Read more >
ion-reorder - Ionic Framework
Reorder is a component that allows an item to be dragged to change its order within a group of items. It must be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found