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.

MdSidenav should not have min-width

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Developer should be able to set the width of MdSidenav element

What is the current behavior?

A Developer can set the width in several ways. Using CSS:

md-sidenav {
  width: 200px;
}

Using binding:

<md-sidenav [style.width]="...">

or ngStyle

The above will work as long as the width is greater then 5% of the container (MdSidenavLayout) There is a CSS rule md-sidenav {min-width: 5%} https://github.com/angular/material2/blob/master/src/components/sidenav/sidenav.scss#L116

Since MdSidenav is shadowed via emulation it’s hard to change that behaviour, the only option is to set min-width: unset inline, which requires a bind or using the renderer.

What is the use-case or motivation for changing an existing behavior?

An app can have a small md-sidenav for icons, very common use case. min-width should be a decision made by the developer.

Which versions of Angular, Material, OS, browsers are affected?

all

Is there anything else we should know?

In general, the “themed” approach for material design in angular 1 worked great but it raises some problems in angular 2. In ng1 a developer had a theme which helped keeping look and feel consistent. In some special cases it might be needed to have a custom color not in the theme palette, having a special CSS selector for that solved the issue. In Angular 2 however, it’s get tricky since shadow dom get’s applied. For example, having a custom background color for md-sidenav is not straight forward since background color is fixed to the theme’s bg color and it’s shadowed. The solution is to inline styles or have a container inside the sidenav with 100% h/w and the color needed.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
shlomiassafcommented, Jun 14, 2016

@jelbourn Thanks.

If someone is placing a sidenav without content he should expect an empty sidenav.

Isn’t it similar if someone creates <h1></h1> and see’s nothing?

If one wants width in an empty sidenav it should be explicitly set.

1reaction
msegerscommented, Jul 18, 2016

It depends on the use case but as @shlomiassaf mentions, it makes sense to have it not appearing visually. Since also no margins are provided by default, I believe the same philosophy of “Define it yourself” applies here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change width of a Sidenav in Angular Material Design?
In angular material, md-sidenav has these attributes: width: 304px; min-width: 304px;. That's why the width will be fixed at 304 px no matter...
Read more >
Directives > mdSidenav - AngularJS Material
A Sidenav component that can be opened and closed programmatically. By default, upon opening it will slide out on top of the main...
Read more >
Side navigation sizing - Dashboard - Node-RED Forum
I would like to increase the size of the side navigation menu in the ... but width only works to a certain extent...
Read more >
How to change width of a Sidenav in Angular Material Design
In angular material, md-sidenav has these attributes: width: 304px; min-width: 304px;. That's why the width will be fixed at 304 px no matter...
Read more >
angular/material2 - Gitter
i can control the width of <md-sidenav> with .app-sidenav {min-width} when sidenav is ... @DzmitryShylovich I have looked at this but I don't...
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