Hi, I’m using the default ion-split-pane from the starter template.
It’s perfect for small and large screens, but not really good middle screens. Can I show a smaller/thinner ion-split-pane on middle screens? Something like when="(min-width: 300px) and (max-width: 500px)"
So it would be:
small: burger menu
middle: thin sidemenu only icon
large: full sidemenu icon and text
Use this on the icon and label child elements of the menu links. I had to create 3 instances since it seems you cannot apply an up AND down utility class to 1 element. to implement the custom width breakpoints, either alter them in the global styles, or use a media query on the specific ion-icons and labels, and adjust the split-pane/menu css
Finally, add the previously referenced css for the ion-spilt-pane and ion-menu.
You could potentially look at creating a custom component that contains this template/css but aside from that, let me know if this yields the correct results for you or if you find something simpler
app.component.html – modify the ion-item as follows:
<!-- Icon and label for hamburger menu at xs breakpoint -->
<ion-icon class="ion-hide-sm-up" slot="start" [ios]="p.icon + '-outline'" [md]="p.icon + '-sharp'"></ion-icon>
<ion-label class="ion-hide-sm-up">{{ p.title }}</ion-label>
<!-- icon only for sm 'modern' style -->
<ion-icon class="ion-hide-sm-down ion-hide-md-up" [ios]="p.icon + '-outline'" [md]="p.icon + '-sharp'"></ion-icon>
<!-- icon and label again for full size menu -->
<ion-icon class="ion-hide-md-down" slot="start" [ios]="p.icon + '-outline'" [md]="p.icon + '-sharp'"></ion-icon>
<ion-label class="ion-hide-md-down">{{ p.title }}</ion-label>
Last question:
In the icon only version, the label is just missing. This has the consequence that the icons are on the same place (left) and on the right remains empty space. Any change to center them? With margin and padding I’d no chance.
getting everything set up on stackblitz was kind of tricky:
i could not get ionicons to implement correctly, copied all my dependenices so id recommend running it locally, but seems like a stackblitz issue
so if anyone has a solution that would be great, seems like there was a problem with ionic 4 and loading in the icons to stackblitz but idk how that compares to now