1

My Angular Material sidenav is not having its CSS applied. Any idea of what's wrong?

Component CSS:

.nav-title {
    color:orangered ;
    font-weight: 500 ;
}

.orange {
    border-top-style: solid ;
    border-top-color: orangered ;
    border-top-width: 2px ;
}

Component HTML

    <mat-sidenav-container>

                <mat-sidenav #sidenav mode="side" 
                             [fixedInViewport]="'true'" [fixedTopGap]="'0'"
                             [fixedBottomGap]="'0'">



                             <app-navigation></app-navigation>



            </mat-sidenav>


            <mat-sidenav-content >


                    <nav class="uk-navbar-container orange" uk-sticky="bottom: #offset" uk-navbar>
                            <div class="uk-navbar-left uk-padding-small"><button (click)="sidenav.toggle()" class="uk-button uk-button-text  uk-margin-small-right" type="button" ><span uk-icon="icon: menu; ratio: 2" ></span></button><div class="nav-title">{{ title }}</div></div>
                            <div class="uk-navbar-center"></div>
                            <div class="uk-navbar-right"></div>
                        </nav>

                    <router-outlet></router-outlet>

            </mat-sidenav-content>

Any guidance would be much appreciated.

Thank you!

user1797508
  • 292
  • 5
  • 16

2 Answers2

1

if you want to add the classes in your component css you need to do it by ::ng-deep or you need to add the classes in your global css file styles.css

Please try with thoes exaples

  1. in component.css
::ng-deep .nav-title {
    color:orangered !important;
    font-weight: 500  !important;
}

::ng-deep .orange {
    border-top-style: solid  !important;
    border-top-color: orangered  !important;
    border-top-width: 2px  !important;
}
  1. in styles.css
.nav-title {
    color:orangered !important;
    font-weight: 500  !important;
}

.orange {
    border-top-style: solid  !important;
    border-top-color: orangered  !important;
}  
Nicholas K
  • 15,148
  • 7
  • 31
  • 57
Ashot Aleqsanyan
  • 4,252
  • 1
  • 15
  • 27
0

Looks like you forgot . before the css class selector:

.nav-title {
    ...
}

.orange {
    ...
}
igor_c
  • 1,200
  • 1
  • 8
  • 20