Skip to content

Instantly share code, notes, and snippets.

@pawelel
Created October 16, 2021 11:44
Show Gist options
  • Save pawelel/fdbd8af84d54f36078b524e2446ac225 to your computer and use it in GitHub Desktop.
Save pawelel/fdbd8af84d54f36078b524e2446ac225 to your computer and use it in GitHub Desktop.
MudBlazor horizontal menu alternative
<style>
.mud-expand-panel, .muudstrap-navbar-expand{
color: var(--mud-palette-appbar-text);
background-color: var(--mud-palette-appbar-background);
}
.muudstrap-navbar .mud-button{
text-transform: none;
}
.muudstrap-navbar .mud-expand-panel-header{
padding:0px;
width: 100%;
height: 100%;
flex:none;
}
</style>
<MudThemeProvider Theme="MuudstrapTheme" />
<MudAppBar Fixed="false" Elevation="0" DisableGutters="true" Class="muudstrap-navbar">
<div class="d-none d-md-flex align-center px-6">
<MudPaper Height="36px" Width="36px" Elevation="0" Class="pa-1 rounded-lg d-flex justify-center align-center mud-theme-primary">
<MudText Typo="Typo.h6">M</MudText>
</MudPaper>
<MudText Typo="Typo.h6" Class="ml-4 mr-12 pt-1 pb-2">Muudstrap</MudText>
<MudButton Color="Color.Inherit" Link="/">Home</MudButton>
<MudButton Color="Color.Inherit" Link="/features">Features</MudButton>
<MudButton Color="Color.Inherit" Link="/pricing">Pricing</MudButton>
<MudMenu Color="Color.Inherit" Label="Dropdown link" EndIcon="@Icons.Material.Filled.ArrowDropDown" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft">
<MudMenuItem Link="/action">Action</MudMenuItem>
<MudMenuItem Link="/another-action">Another action</MudMenuItem>
<MudMenuItem Link="/something-else-here">Something else here</MudMenuItem>
</MudMenu>
</div>
<div class="d-flex d-md-none relative mud-width-full mud-height-full">
<MudExpansionPanels Square="true" Elevation="0" Class="absolute mud-width-full mud-height-full" Style="top:0px;left:0; background-color:Inherit;">
<MudExpansionPanel HideIcon="true" Class="mud-width-full mud-height-full">
<TitleContent>
<div class="d-flex justify-space-between mud-width-full align-center px-6">
<div class="d-flex align-center">
<MudPaper Height="36px" Width="36px" Elevation="25" Class="pa-1 rounded-lg d-flex justify-center align-center mud-theme-primary">
<MudText Typo="Typo.h6">M</MudText>
</MudPaper>
<MudText Typo="Typo.h6" Class="ml-4 mr-12 pt-1 pb-2">Muudstrap</MudText>
</div>
<MudIcon Icon="@Icons.Material.Filled.Menu" />
</div>
</TitleContent>
<ChildContent>
<div class="py-6 mx-n6 muudstrap-navbar-expand">
<MudNavMenu>
<MudNavLink Href="/">Home</MudNavLink>
<MudNavLink Href="/features">Features</MudNavLink>
<MudNavLink Href="/pricing">Pricing</MudNavLink>
</MudNavMenu>
</div>
</ChildContent>
</MudExpansionPanel>
</MudExpansionPanels>
</div>
</MudAppBar>
@code{
MudTheme MuudstrapTheme = new MudTheme()
{
Palette = new Palette()
{
AppbarBackground = "#f8f9fa",
AppbarText = "#181819"
},
Typography = new Typography()
{
H6 = new H6()
{
FontFamily = new[] { "system-ui", "-apple-system" ,"Segoe UI", "Roboto ","Helvetica Neue", "Arial","Noto Sans","Liberation Sans", "sans-serif" ,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji" },
FontSize = "1.25rem",
FontWeight = 400,
LineHeight = 1.7,
LetterSpacing = "normal"
},
Button = new Button()
{
FontFamily = new[] { "system-ui", "-apple-system" ,"Segoe UI", "Roboto ","Helvetica Neue", "Arial","Noto Sans","Liberation Sans", "sans-serif" ,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji" },
FontSize = "1rem",
FontWeight = 400,
LineHeight = 1.5,
LetterSpacing = "normal"
}
}
};
}
@pawelel
Copy link
Author

pawelel commented Oct 16, 2021

Credits: Garderoben

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment