# 2019 ionic 4 custom ion-menu width not working

**URL:** <https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766>\
**Category:** ionic-v3\
**Created:** [April 16, 2019, 1:42pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766 "2019-04-16T13:42:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![SanduCuragau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sanducuragau/32/125297_2.png) [@SanduCuragau](https://forum.ionicframework.com/u/SanduCuragau)\
**Post date:** [April 16, 2019, 1:42pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/1 "2019-04-16T13:42:15Z")

</div>

Cheers I have an ion menu that I wanna make smaller, about 50% of the screen instead of the default width. I swear I have checked out every single post on the ionic forum and stackoverflow about this and tried everything people have posted in the past but nothing worked, what am I supposed to do to get it done?

---

<div class="post-metadata">

**Author:** ![jjdev](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jjdev](https://forum.ionicframework.com/u/jjdev)\
**Post date:** [April 16, 2019, 1:52pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/2 "2019-04-16T13:52:44Z")

</div>

Can you post your css?

I’d check [here](https://ionicframework.com/docs/api/menu#css-custom-properties) for menu css variables

---

<div class="post-metadata">

**Author:** ![SanduCuragau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sanducuragau/32/125297_2.png) [@SanduCuragau](https://forum.ionicframework.com/u/SanduCuragau)\
**Post date:** [April 16, 2019, 1:58pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/3 "2019-04-16T13:58:19Z")

</div>

Cheers, ye sure, although I don’t think I have anything special in my css, just some simple stuff to make the side menu look better

 ![Screenshot_7](https://global.discourse-cdn.com/ionicframework/original/3X/6/4/640f4a7f362405d7b5129160a8c5ef2dfd269ffe.png)  
Well yeah I have tried every bit of css I have found on forums to make the side menu smaller but nothing has worked

---

<div class="post-metadata">

**Author:** ![jjdev](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jjdev](https://forum.ionicframework.com/u/jjdev)\
**Post date:** [April 16, 2019, 2:12pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/4 "2019-04-16T14:12:26Z")

</div>

Try adding `--max-width: 200px` or your desired width to the ion-menu-button block  
If you want the menu smaller than default use --max-width, and if you want it larger use --min-width

---

<div class="post-metadata">

**Author:** ![SanduCuragau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sanducuragau/32/125297_2.png) [@SanduCuragau](https://forum.ionicframework.com/u/SanduCuragau)\
**Post date:** [April 16, 2019, 2:26pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/5 "2019-04-16T14:26:51Z")

</div>

Where and how exactly do I use the max and min width tags? Because I have tried them already, both with inline styling aswell as putting it in the global.scss for the ion-menu and it just doesn’t work

---

<div class="post-metadata">

**Author:** ![jjdev](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jjdev](https://forum.ionicframework.com/u/jjdev)\
**Post date:** [April 16, 2019, 2:32pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/6 "2019-04-16T14:32:52Z")

</div>

```auto
ion-menu {
    --max-width: 200px;
    // OR
    --min-width: 200px;
}

```

Also check your package.json to make sure you’re on the latest `@ionic/angular` version

---

<div class="post-metadata">

**Author:** ![SanduCuragau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sanducuragau/32/125297_2.png) [@SanduCuragau](https://forum.ionicframework.com/u/SanduCuragau)\
**Post date:** [April 16, 2019, 2:42pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/7 "2019-04-16T14:42:20Z")

</div>

Welp that was the first thing I tried like 2 hours ago, doesn’t work.  
Also yes I am running the latest version of ionic/angular.

---

<div class="post-metadata">

**Author:** ![jjdev](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jjdev](https://forum.ionicframework.com/u/jjdev)\
**Post date:** [April 16, 2019, 3:01pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/8 "2019-04-16T15:01:40Z")

</div>

Is `'./app.component.scss'` added to your app.component.ts `@Component` styleUrls array? I’ve noticed the ionic CLI doesn’t give you an app component css page to start

---

<div class="post-metadata">

**Author:** ![SanduCuragau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sanducuragau/32/125297_2.png) [@SanduCuragau](https://forum.ionicframework.com/u/SanduCuragau)\
**Post date:** [April 16, 2019, 3:17pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/9 "2019-04-16T15:17:22Z")

</div>

I am using the sidemenu template, not the blank one, and it didn’t create a component.scss  
 ![Screenshot_11](https://global.discourse-cdn.com/ionicframework/original/3X/b/a/ba9e1834368b7fb3bb396e94d5afc1243bb8850d.png)  
and since the menu’s html is in the component.html and I dont have a scss file just for it, I put the scss code for the ion-menu in the global.scss file, but I’ve tried in line styling the ion-menu aswell

---

<div class="post-metadata">

**Author:** ![jjdev](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jjdev](https://forum.ionicframework.com/u/jjdev)\
**Post date:** [April 16, 2019, 3:23pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/10 "2019-04-16T15:23:29Z")

</div>

You can manually add a scss called `app.component.scss` and add

```auto
styleUrls: ['./app.component.scss']

```

To your app.component.ts `@Component` decorator. This way you can maintain styling similar to the rest of the pages/components. I think it has to be applied to the app component, not globally

---

<div class="post-metadata">

**Author:** ![SanduCuragau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sanducuragau/32/125297_2.png) [@SanduCuragau](https://forum.ionicframework.com/u/SanduCuragau)\
**Post date:** [April 16, 2019, 4:59pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/11 "2019-04-16T16:59:02Z")

</div>

Welp it didn’t work again using  
ion-menu {  
–max-width: 200px;  
}  
in the newly created `app.component.scss`, i just got mad, created a new project and copy pasted all the pages and services and scss and assests into the new project, and now it works perfectly.  
I’m left with no words, thanks mate for trying to help me out but turns out it was something to do with the project, when everything is fully updated on a clear project, its working perfectly!

---

<div class="post-metadata">

**Author:** ![jjdev](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jjdev](https://forum.ionicframework.com/u/jjdev)\
**Post date:** [April 16, 2019, 5:06pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/12 "2019-04-16T17:06:45Z")

</div>

Wow. yeah that’s really weird because my examples were how I’ve definitely achieved it before so I’m not sure what would have been preventing it in your project and not in a new one. Good thinking though!

---

<div class="post-metadata">

**Author:** ![SanduCuragau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sanducuragau/32/125297_2.png) [@SanduCuragau](https://forum.ionicframework.com/u/SanduCuragau)\
**Post date:** [April 16, 2019, 11:20pm UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/13 "2019-04-16T23:20:08Z")

</div>

There is something else in my mind now, I was thinking of replacing the static width’s value  
ion-menu {  
–max-width: 200px;  
}  
in the scss file to something more dynamic like, if he is logged in then have a max width and if he isn’t then have another, I tried this:  
\<ion-menu [–max-width]=“isLoggedIn ? ‘275px’ : ‘200px’”\>  
but console outputs “Can’t bind to ‘–max-width’ since it isn’t a known property of ‘ion-menu’.”  
I tried with max-width too, doesn’t recognize the property

Do you have any ideas how I could accomplish this?

---

<div class="post-metadata">

**Author:** ![jjdev](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jjdev](https://forum.ionicframework.com/u/jjdev)\
**Post date:** [April 17, 2019, 1:58am UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/14 "2019-04-17T01:58:33Z")

</div>

Try

```auto
[ngStyle]="{'--max-width': isLoggedIn ? '275px' : '200px'}"

```

---

<div class="post-metadata">

**Author:** ![SanduCuragau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sanducuragau/32/125297_2.png) [@SanduCuragau](https://forum.ionicframework.com/u/SanduCuragau)\
**Post date:** [April 17, 2019, 9:00am UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/15 "2019-04-17T09:00:20Z")

</div>

I just looked up the syntax for a conditional ngstyle and what you proposed really seems to be it, but unfortunately it’s not working, its not giving me any error about it in the console, but it isn’t changing the menu’s width either, have you used something like this before?

---

<div class="post-metadata">

**Author:** ![SanduCuragau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sanducuragau/32/125297_2.png) [@SanduCuragau](https://forum.ionicframework.com/u/SanduCuragau)\
**Post date:** [April 17, 2019, 9:21am UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/16 "2019-04-17T09:21:09Z")

</div>

For now I’m going to be doing this, since it works

HTML:  
\<ion-menu type=“overlay” [class.menuBig]=‘isLoggedIn’ [class.menuSmall]=’!isLoggedIn’\>

SCSS:  
.menuSmall{  
–max-width: 200px;  
}

.menuBig{  
–max-width: 270px;  
}

but I really wanted the conditional ngStyle to work exactly like you suggested since its way more clean, I tried another conditional ngstyle and it worked, so I’m guessing it’s not working on the property --max-width

---

<div class="post-metadata">

**Author:** ![Andrea8376](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@Andrea8376](https://forum.ionicframework.com/u/Andrea8376)\
**Post date:** [April 17, 2019, 10:23am UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/17 "2019-04-17T10:23:29Z")

</div>

ion-menu position is absolute. and u will have to change width of ion-header, ion-content, ion-footer inside that ion-menu. [TTRockStars](https://ttrockstars.org/)

---

<div class="post-metadata">

**Author:** ![jjdev](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jjdev](https://forum.ionicframework.com/u/jjdev)\
**Post date:** [April 17, 2019, 11:37am UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/18 "2019-04-17T11:37:39Z")

</div>

Ah my mistake  
Can you use ngClass in a similar way?, Have 2 classes with your --max-width values, and toggle between those

---

<div class="post-metadata">

**Author:** ![SanduCuragau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sanducuragau/32/125297_2.png) [@SanduCuragau](https://forum.ionicframework.com/u/SanduCuragau)\
**Post date:** [April 17, 2019, 11:40am UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/19 "2019-04-17T11:40:58Z")

</div>

The code I shared works perfectly, I just wished the ngStyle worked aswell since it is way more clean but its alright, thank you for your help!

---

<div class="post-metadata">

**Author:** ![jjdev](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jjdev](https://forum.ionicframework.com/u/jjdev)\
**Post date:** [April 17, 2019, 11:58am UTC](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766/20 "2019-04-17T11:58:24Z")

</div>

NgClass is slightly more clean, only 1 line

```auto
[ngClass]="{'menuSmall': !isLoggedIn, 'menuBig': isLoggedIn}"

```

But this should work exactly the same to your `[class.xxxxx]`

[Next page](https://forum.ionicframework.com/t/2019-ionic-4-custom-ion-menu-width-not-working/161766.md?page=2)
