NavBar
NavMenu
TabPanel
NavMenu
TabPanel
A tab panel that provides navigation links to the main areas of an app.
Notes
The BitNavBar is a Multi-API component
which can accept the list of Items in 3 different ways:
1. The BitNavBarItem class
2. A Custom Generic class
3. The BitNavBarOption component
Usage
Basic
<BitNavBar Items="basicNavBarItems" />@code { private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
Disabled
Disabled:
Disabled item:
<BitNavBar Items="basicNavBarItems" IsEnabled="false" /> <BitNavBar Items="basicNavBarItemsDisabled" />@code { private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; private static readonly List<BitNavBarItem> basicNavBarItemsDisabled = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools, IsEnabled = false }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
Manual Mode
Defines the mode in which the selected item is handled manually, instead of automatically using the current url.
<BitNavBar Mode="BitNavMode.Manual" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" />@code { private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
IconOnly
Only renders the icon of each navbar item.
<BitNavBar Items="basicNavBarItems" IconOnly />@code { private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
FitWidth
Enables fit-content width for the nav bar that sets the width of the component based on its content size.
<BitNavBar Items="basicNavBarItems" FitWidth />@code { private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
Templates
Explore BitNavBar's customization capabilities.
ItemTemplate:
Item's template:
<BitNavBar Items="basicNavBarItems"> <ItemTemplate Context="item"> <BitText Typography="BitTypography.Caption1" Color="BitColor.Warning">@item.Text</BitText> <BitIcon IconName="@item.IconName" Color="BitColor.Success" /> </ItemTemplate> </BitNavBar> <BitNavBar Items="templateNavBarItems" /> @code { private static readonly List<BitNavBarItem> templateNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", Template = (item) => @<div style="display:flex;flex-direction:column"><b>@item.Text</b><span>🎁</span></div> }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }@code { private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
Events
Managing NavBar item click event (OnItemClick).
Clicked item:
<BitNavBar Items="basicNavBarItems" OnItemClick="(BitNavBarItem item) => eventsClickedItem = item" /> Clicked item: @eventsClickedItem?.Text@code { private BitNavBarItem? eventsClickedItem; private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
Binding
This example demonstrates different ways to handle item selection and changes within the component.
DefaultSelectedItem:
Selected item: Home
Two-way SelectedItem:
<BitNavBar Items="basicNavBarItems" Mode="BitNavMode.Manual" @bind-SelectedItem="selectedItem" DefaultSelectedItem="basicNavBarItems[1]" /> Selected item: @selectedItem.Text <BitNavBar Items="basicNavBarItems" Mode="BitNavMode.Manual" @bind-SelectedItem="twoWaySelectedItem" /> <BitChoiceGroup Horizontal Items="@choiceGroupItems" @bind-Value="@twoWaySelectedItem" />@code { private BitNavBarItem selectedItem = basicNavBarItems[0]; private BitNavBarItem twoWaySelectedItem = basicNavBarItems[0]; private static IEnumerable<BitChoiceGroupItem<BitNavBarItem>> choiceGroupItems = basicNavBarItems.Select(i => new BitChoiceGroupItem<BitNavBarItem>() { Id = i.Text, Text = i.Text, IsEnabled = i.IsEnabled, Value = i }); private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
Reselectable
Enables the ability to trigger select event even when the same item is selected again.
Item click count: 0
<BitToggle @bind-Value="reselectable" OnText="Enabled recalling" OffText="Disabled recalling" /> <BitNavBar Items="basicNavBarItems" Mode="BitNavMode.Manual" Reselectable="reselectable" OnItemClick="(BitNavBarItem item) => countClick++" /> Item click count: @countClick@code { private int countClick; private bool reselectable = true; private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
Advanced
An illustrative example of integrating this component into a straightforward mobile application.
bit BlazorUI
Products
<style> .mobile-frame { height: 666px; overflow: hidden; max-width: 375px; position: relative; border-radius: 36px; background-color: gray; border: 16px solid #333; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } .mobile-frame::after { top: 10px; left: 50%; content: ''; width: 60px; height: 5px; display: block; background: #333; position: absolute; border-radius: 10px; transform: translateX(-50%); } .screen { width: 100%; height: 100%; display: flex; flex-direction: column; } </style> <div class="mobile-frame"> <div class="screen"> <BitSticky Top="0"> <BitCard FullWidth> <BitStack Horizontal HorizontalAlign="BitAlignment.Center" VerticalAlign="BitAlignment.Center"> <BitImage Src="/images/bit-logo.svg" Width="50" /> <BitText Typography="BitTypography.H4" Color="BitColor.Info"> bit BlazorUI </BitText> </BitStack> </BitCard> </BitSticky> <BitStack Alignment="BitAlignment.Center" AutoHeight Grows> <BitText Typography="BitTypography.H4" Color="BitColor.PrimaryForeground"> <BitIcon IconName="@advancedSelectedItem.IconName" Color="BitColor.PrimaryForeground" Size="BitSize.Large" /> <span>@advancedSelectedItem.Text</span> </BitText> </BitStack> <BitSticky Bottom="0"> <BitCard FullWidth Style="padding:2px"> <BitNavBar Items="basicNavBarItems" Mode="BitNavMode.Manual" @bind-SelectedItem="advancedSelectedItem" /> </BitCard> </BitSticky> </div> </div>@code { private BitNavBarItem advancedSelectedItem = basicNavBarItems[1]; private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
Color
Offering a range of specialized colors, providing visual cues for specific states within your application.
Primary:
Secondary:
Tertiary:
Info:
Success:
Warning:
SevereWarning:
Error:
PrimaryBackground:
SecondaryBackground:
TertiaryBackground:
PrimaryForeground:
SecondaryForeground:
TertiaryForeground:
PrimaryBorder:
SecondaryBorder:
TertiaryBorder:
<BitNavBar Color="BitColor.Primary" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.Secondary" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.Tertiary" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.Info" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.Success" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.Warning" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.SevereWarning" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.Error" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.PrimaryBackground" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.SecondaryBackground" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.TertiaryBackground" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.PrimaryForeground" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.SecondaryForeground" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.TertiaryForeground" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.PrimaryBorder" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.SecondaryBorder" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" /> <BitNavBar Color="BitColor.TertiaryBorder" Items="basicNavBarItems" DefaultSelectedItem="basicNavBarItems[0]" Mode="BitNavMode.Manual" />@code { private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
Style & Class
Empower customization by overriding default styles and classes, allowing tailored design modifications to suit specific UI requirements.
Component's Style:
Component's Class:
Item's style & class:
Styles:
Classes:
<style> .custom-class { margin: 1rem; border-radius: 1rem; box-shadow: aqua 0 0 1rem; background: linear-gradient(90deg, magenta, transparent) blue; } .custom-item { color: #ff7800; font-weight: 600; } .custom-item-ico { font-weight: bold; color: darkmagenta; } .custom-item-txt { font-weight: bold; font-style: italic; } </style> <BitNavBar Items="basicNavBarItems" Style="border-radius: 1rem; margin: 1rem; box-shadow: tomato 0 0 1rem;" /> <BitNavBar Items="basicNavBarItems" Class="custom-class" /> <BitNavBar Items="styleClassItems" /> <BitNavBar Items="basicNavBarItems" Styles="@(new() { ItemIcon = "color: aqua;", ItemText = "color: tomato;" })" /> <BitNavBar Items="basicNavBarItems" Classes="@(new() { ItemIcon = "custom-item-ico", ItemText = "custom-item-txt" })" />@code { private static readonly List<BitNavBarItem> basicNavBarItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant }, new() { Text = "Academy", IconName = BitIconName.LearningTools }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; private static readonly List<BitNavBarItem> styleClassItems = [ new() { Text = "Home", IconName = BitIconName.Home }, new() { Text = "Products", IconName = BitIconName.ProductVariant, Class = "custom-item" }, new() { Text = "Academy", IconName = BitIconName.LearningTools, Style = "color: #b6ff00;font-weight: 600;" }, new() { Text = "Profile", IconName = BitIconName.Contact }, ]; }
RTL
Use BitNavBar in right-to-left (RTL).
<BitNavBar Dir="BitDir.Rtl" Items="rtlItems" />@code { private static readonly List<BitNavBarItem> rtlItems = [ new() { Text = "خانه", IconName = BitIconName.Home }, new() { Text = "محصولات", IconName = BitIconName.ProductVariant }, new() { Text = "آکادمی", IconName = BitIconName.LearningTools }, new() { Text = "پروفایل", IconName = BitIconName.Contact }, ]; }
API
BitNavBar parameters
Name |
Type |
Default value |
Description |
|---|---|---|---|
| ChildContent | RenderFragment? | null | Items to render as children. |
| Classes | BitNavClassStyles? | null | Custom CSS classes for different parts of the navbar. |
| Color | BitColor? | null | The general color of the navbar. |
| DefaultSelectedItem | TItem? | null | The initially selected item in manual mode. |
| FitWidth | bool | false | Renders the nav bat in a width to only fit its content. |
| FullWidth | bool | false | Renders the nav bar in full width of its container element. |
| IconOnly | bool | false | Only renders the icon of each navbar item. |
| Items | IList<TItem> | new List<TItem>() | A collection of items to display in the navbar. |
| ItemTemplate | RenderFragment<TItem>? | null | Used to customize how content inside the item is rendered. |
| Mode | BitNavMode | BitNavMode.Automatic | Determines how the navigation will be handled. |
| NameSelectors | BitNavNameSelectors<TItem>? | null | Names and selectors of the custom input type properties. |
| OnItemClick | EventCallback<TItem> | Callback invoked when an item is clicked. | |
| OnSelectItem | EventCallback<TItem> | Callback invoked when an item is selected. | |
| Options | RenderFragment? | null | Alias of ChildContent. |
| Reselectable | bool | false | Enables recalling the select events when the same item is selected. |
| SelectedItem | TItem? | null | Selected item to show in the navbar. |
| Styles | BitNavClassStyles? | null | Custom CSS styles for different parts of the navbar. |
BitComponentBase parameters
Name |
Type |
Default value |
Description |
|---|---|---|---|
| AriaLabel | string? | null | The aria-label of the control for the benefit of screen readers. |
| Class | string? | null | Custom CSS class for the root element of the component. |
| Dir | BitDir? | null | Determines the component direction. |
| HtmlAttributes | Dictionary<string, object> | new Dictionary<string, object>() | Capture and render additional attributes in addition to the component's parameters. |
| Id | string? | null | Custom id attribute for the root element. if null the UniqueId will be used instead. |
| IsEnabled | bool | true | Whether or not the component is enabled. |
| Style | string? | null | Custom CSS style for the root element of the component. |
| Visibility | BitVisibility | BitVisibility.Visible | Whether the component is visible, hidden or collapsed. |
BitComponentBase public members
Name |
Type |
Default value |
Description |
|---|---|---|---|
| UniqueId | Guid | Guid.NewGuid() | The readonly unique id of the root element. it will be assigned to a new Guid at component instance construction. |
| RootElement | ElementReference | The ElementReference of the root element. |
BitNavBarNameSelectors<TItem> properties
Name |
Type |
Default value |
Description |
|---|---|---|---|
| Class | BitNameSelectorPair<TItem, string?> | new(nameof(BitNavBarItem.Class)) | The Class field name and selector of the custom input class. |
| Data | BitNameSelectorPair<TItem, object?> | new(nameof(BitNavBarItem.Data)) | The Data field name and selector of the custom input class. |
| IconName | BitNameSelectorPair<TItem, string?> | new(nameof(BitNavBarItem.IconName)) | The IconName field name and selector of the custom input class. |
| IsEnabled | BitNameSelectorPair<TItem, bool?> | new(nameof(BitNavBarItem.IsEnabled)) | The IsEnabled field name and selector of the custom input class. |
| Key | BitNameSelectorPair<TItem, string?> | new(nameof(BitNavBarItem.Key)) | The Key field name and selector of the custom input class. |
| Style | BitNameSelectorPair<TItem, string?> | new(nameof(BitNavBarItem.Style)) | The Style field name and selector of the custom input class. |
| Target | BitNameSelectorPair<TItem, string?> | new(nameof(BitNavBarItem.Target)) | The Target field name and selector of the custom input class. |
| Template | BitNameSelectorPair<TItem, RenderFragment<TItem>?> | new(nameof(BitNavBarItem.Template)) | The Template field name and selector of the custom input class. |
| Text | BitNameSelectorPair<TItem, string?> | new(nameof(BitNavBarItem.Text)) | The Text field name and selector of the custom input class. |
| Title | BitNameSelectorPair<TItem, string?> | new(nameof(BitNavBarItem.Title)) | The Title field name and selector of the custom input class. |
| Url | BitNameSelectorPair<TItem, string?> | new(nameof(BitNavBarItem.Url)) | The Url field name and selector of the custom input class. |
| AdditionalUrls | BitNameSelectorPair<TItem, IEnumerable<string>?> | new(nameof(BitNavBarItem.AdditionalUrls)) | The AdditionalUrls field name and selector of the custom input class. |
BitNavBarClassStyles properties
Name |
Type |
Default value |
Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the root element of the BitNavBar. |
| Container | string? | null | Custom CSS classes/styles for the container of the items of the BitNavBar. |
| Item | string? | null | Custom CSS classes/styles for the item of the BitNavBar. |
| ItemIcon | string? | null | Custom CSS classes/styles for the item icon of the BitNavBar. |
| ItemText | string? | null | Custom CSS classes/styles for the item text of the BitNavBar. |
| SelectedItem | string? | null | Custom CSS classes/styles for the selected item of the BitNavBar. |
BitVisibility enum
Name |
Value |
Description |
|---|---|---|
| Visible | 0 | The content of the component is visible. |
| Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). |
| Collapsed | 2 | The component is hidden (display:none). |
BitDir enum
Name |
Value |
Description |
|---|---|---|
| Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). |
| Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). |
| Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. |
Feedback
You can give us your feedback through our GitHub repo by filing a new Issue or starting a new Discussion.
Or you can review / edit this page on GitHub.
Or you can review / edit this component on GitHub.
- On this page