Search code examples
cssblazor-server-sidemudblazor

MudBlazor - not able to change MudTable header text color


I'm adding MudBlazor to my first Blazer Server project. I'm trying to tweak the looks of the MudTable to match other projects. I was able to get the header background color to change but I'm not able to figure out what needs to change to make the text white. I would also like to change the left border of each header cell to match that of the border.

This is the CSS I added to get the background color correct but the text is not getting changed to white.

.mud-table-header {
    background-color: #0078d2;
    color: white !important;
}



 <MudTable Items="@listApplications" Dense="true" Hover="true" Bordered="true" Striped="true" HeaderClass="mud-table-header"
            Filter="new Func<UsersAdminApp,bool>(FilterFunc1)" @bind-SelectedItem="selectedApplication">
        <HeaderContent>
            <MudTh>
                <MudTableSortLabel Enabled="true" InitialDirection="SortDirection.Ascending" SortBy="new Func<UsersAdminApp, object>(x=>x.Name)">Name</MudTableSortLabel>
            </MudTh>
            <MudTh>Description</MudTh>
            <MudTh></MudTh>
        </HeaderContent>

Solution

  • To change the color of the MudTable headers, you can target either the mud-table-cell CSS class or the th element.

    <style>
        .mud-table-header {
        background-color: #0078d2;
        }
        .mud-table-header .mud-table-cell{
        color: white !important;
        }
    </style>
    

    MudBlazor Snippet