background and textcolor navbar Blazor
Asked Answered
E

4

7

I would like to change the background color of a navbar in Blazor, but I cannot find the way to do it. It cannot be that difficult, I guess. Can anybody tell me?

<div class="top-row pl-4 navbar navbar-dark bg-primary ">
    <a class="navbar-brand bg-primary" href="">Test</a>
    <button class="navbar-toggler bg-primary" @onclick="ToggleNavMenu">
        <span class="navbar-toggler-icon bg-primary"></span>
    </button>
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
    <ul class="nav flex-column">
        <li class="nav-item px-3 bg-primary">
            <NavLink class="nav-link" href="" Match="NavLinkMatch.All">
                <span class="oi oi-home" aria-hidden="true"></span> Home
            </NavLink>
        </li>
        <li class="nav-item px-3 bg-primary oi-resize-height">
            <NavLink class="nav-link" href="hd">
                <span class="oi oi-list-rich" aria-hidden="true"></span> hd
            </NavLink>
        </li>
    </ul>
</div>
Equinoctial answered 5/5, 2020 at 10:19 Comment(1)
The answer is probably in the bootstrap 4 doc : getbootstrap.com/docs/4.4/components/navbar/#color-schemesKg
S
10

In "MainLayout.razor"

<div style="background-image:none;background-color:cadetblue;" class="sidebar">
    <NavMenu />
</div>
Sheen answered 12/10, 2020 at 7:45 Comment(0)
F
3

The answer is due to blazor having its own css file we need to change the css there.

To change the background-color of the sidebar and navbar, in MainLayout.razor.css thats where the css is located e.g..sidbar .top-row

and finally to change the background of the area where the "Company/project logo" is going to be, for the the css is under NavMenu.razor.css --> .top-row

Fake answered 24/5, 2022 at 9:37 Comment(0)
E
2

Late answer I was reviewing first posts. In app.css in the client change the sidebar class :

.sidebar {
    background-color: orange;
}
Engedi answered 24/10, 2020 at 4:3 Comment(1)
When using Blazor Server, you can find the sidebar class in the MainLayout.razor.css file.Zoosporangium
M
0

This answer navbar blazer button, remove bg-primary and add bg-secondary bootstrap class is using change the button color.

<button class="navbar-toggler bg-secondary" @onclick="ToggleNavMenu">
    <span class="navbar-toggler-icon "></span>
</button>

// or try this css

.navbar-toggler{
   background:coral !important;
 }
Monasticism answered 5/5, 2020 at 13:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.