Breadcrumb
Breadcrumbs should be used as a navigational aid in your app or site. They indicate the current page’s location within a hierarchy and help the user understand where they are in relation to the rest of that hierarchy. They also afford one-click access to higher levels of that hierarchy.
Notes
The BitBreadcrumb is a Multi-API component
which can accept the list of Items in 3 different ways:
1. The BitBreadcrumbItem class
2. A Custom Generic class
3. The BitBreadcrumbOption component
Usage
Basic
<BitBreadcrumb Items="BreadcrumbItems" /> <BitBreadcrumb Items="BreadcrumbItems" IsEnabled="false" /> <BitBreadcrumb Items="BreadcrumbItemsDisabled" />@code { private readonly List<BitBreadcrumbItem> BreadcrumbItems = [ new() { Text = "Item 1", Href = "/components/breadcrumb" }, new() { Text = "Item 2", Href = "/components/breadcrumb" }, new() { Text = "Item 3", Href = "/components/breadcrumb" }, new() { Text = "Item 4", Href = "/components/breadcrumb", IsSelected = true } ]; private readonly List<BitBreadcrumbItem> BreadcrumbItemsDisabled = [ new() { Text = "Item 1", Href = "/components/breadcrumb", IsEnabled = false }, new() { Text = "Item 2", Href = "/components/breadcrumb", IsEnabled = false }, new() { Text = "Item 3", Href = "/components/breadcrumb" }, new() { Text = "Item 4", Href = "/components/breadcrumb", IsSelected = true } ]; }
MaxDisplayedItems & OverflowIndex
<BitBreadcrumb Items="BreadcrumbItems" MaxDisplayedItems="1" /> <BitBreadcrumb Items="BreadcrumbItems" MaxDisplayedItems="2" /> <BitBreadcrumb Items="BreadcrumbItems" MaxDisplayedItems="3" /> <BitBreadcrumb Items="BreadcrumbItems" MaxDisplayedItems="3" OverflowIndex="0" /> <BitBreadcrumb Items="BreadcrumbItems" MaxDisplayedItems="3" OverflowIndex="1" /> <BitBreadcrumb Items="BreadcrumbItems" MaxDisplayedItems="3" OverflowIndex="2" />@code { private readonly List<BitBreadcrumbItem> BreadcrumbItems = [ new() { Text = "Item 1", Href = "/components/breadcrumb" }, new() { Text = "Item 2", Href = "/components/breadcrumb" }, new() { Text = "Item 3", Href = "/components/breadcrumb" }, new() { Text = "Item 4", Href = "/components/breadcrumb", IsSelected = true } ]; }
Icons
<BitBreadcrumb Items="BreadcrumbItemsWitIcon" DividerIconName="@BitIconName.CaretRightSolid8" OverflowIconName="@BitIconName.ChevronDown" OverflowIndex="2" MaxDisplayedItems="3" /> <BitBreadcrumb Items="BreadcrumbItemsWitIcon" OverflowIconName="@BitIconName.CollapseMenu" MaxDisplayedItems="3" OverflowIndex="2" ReversedIcon />@code { private readonly List<BitBreadcrumbItem> BreadcrumbItemsWitIcon = [ new() { Text = "Item 1", Href = "/components/breadcrumb", IconName = BitIconName.AdminELogoInverse32 }, new() { Text = "Item 2", Href = "/components/breadcrumb", IconName = BitIconName.AppsContent }, new() { Text = "Item 3", Href = "/components/breadcrumb", IconName = BitIconName.AzureIcon }, new() { Text = "Item 4", Href = "/components/breadcrumb", IsSelected = true, IconName = BitIconName.ClassNotebookLogo16 } ]; }
Templates
<BitBreadcrumb Items="BreadcrumbItems"> <DividerIconTemplate> <BitIcon IconName="@BitIconName.CaretRightSolid8" Color="BitColor.Warning" /> </DividerIconTemplate> </BitBreadcrumb> <BitBreadcrumb Items="BreadcrumbItems" MaxDisplayedItems="3" OverflowIndex="2"> <ItemTemplate Context="item"> <div style="font-weight: bold; color: #d13438; font-style:italic;"> @item.Text </div> </ItemTemplate> <OverflowTemplate Context="item"> <div style="font-weight: bold; color: blueviolet; font-style:italic;"> @item.Text </div> </OverflowTemplate> </BitBreadcrumb> <BitBreadcrumb Items="BreadcrumbItemTemplateItems" MaxDisplayedItems="3" OverflowIndex="2" />@code { private readonly List<BitBreadcrumbItem> BreadcrumbItems = [ new() { Text = "Item 1", Href = "/components/breadcrumb" }, new() { Text = "Item 2", Href = "/components/breadcrumb" }, new() { Text = "Item 3", Href = "/components/breadcrumb" }, new() { Text = "Item 4", Href = "/components/breadcrumb", IsSelected = true } ]; private readonly List<BitBreadcrumbItem> BreadcrumbItemTemplateItems = [ new() { Text = "Item 1", Href = "/components/breadcrumb", Template = (item => @<div style="color:green">@item.Text</div>), OverflowTemplate = (item => @<div style="color:green;text-decoration:underline;">@item.Text</div>) }, new () { Text = "Item 2", Href = "/components/breadcrumb", Template = (item => @<div style="color:yellow">@item.Text</div>), OverflowTemplate = (item => @<div style="color:yellow;text-decoration:underline;">@item.Text</div>) }, new() { Text = "Item 3", Href = "/components/breadcrumb", Template = (item => @<div style="color:red">@item.Text</div>), OverflowTemplate = (item => @<div style="color:red;text-decoration:underline;">@item.Text</div>) }, new() { Text = "Item 4", Href = "/components/breadcrumb", IsSelected = true, Template = (item => @<div style="color:blue">@item.Text</div>), OverflowTemplate = (item => @<div style="color:blue;text-decoration:underline;">@item.Text</div>) } ]; }
Events
<BitBreadcrumb Items="@BreadcrumbItemsWithControlled" MaxDisplayedItems="3" OverflowIndex="2" OnItemClick="(BitBreadcrumbItem item) => HandleOnItemClick(item)" Styles="@(new() { SelectedItem = "color: dodgerblue;", OverflowSelectedItem = "color: red;" })" />@code { private readonly List<BitBreadcrumbItem> BreadcrumbItemsWithControlled = [ new() { Text = "Item 1" }, new() { Text = "Item 2" }, new() { Text = "Item 3" }, new() { Text = "Item 4" }, new() { Text = "Item 5" }, new() { Text = "Item 6", IsSelected = true } ]; private void HandleOnItemClick(BitBreadcrumbItem item) { BreadcrumbItemsWithControlled.FirstOrDefault(i => i.IsSelected).IsSelected = false; item.IsSelected = true; } }
Customizations
<BitBreadcrumb Items="@BreadcrumbItemsWithCustomized" MaxDisplayedItems="@MaxDisplayedItems" OverflowIndex="@OverflowIndex" OnItemClick="(BitBreadcrumbItem item) => HandleOnCustomizedItemClick(item)" /> <BitButton OnClick="AddBreadcrumbItem">Add Item</BitButton> <BitButton OnClick="RemoveBreadcrumbItem">Remove Item</BitButton> <BitNumberField @bind-Value="MaxDisplayedItems" Label="Max displayed items" ShowArrows="true" /> <BitNumberField @bind-Value="OverflowIndex" Label="Overflow index" ShowArrows="true" />@code { private int ItemsCount = 4; private uint OverflowIndex = 2; private uint MaxDisplayedItems = 3; private readonly List<BitBreadcrumbItem> BreadcrumbItemsWithCustomized = [ new() { Text = "Item 1" }, new() { Text = "Item 2" }, new() { Text = "Item 3" }, new() { Text = "Item 4", IsSelected = true } ]; private void HandleOnCustomizedItemClick(BitBreadcrumbItem item) { BreadcrumbItemsWithCustomized.FirstOrDefault(i => i.IsSelected).IsSelected = false; item.IsSelected = true; } private void AddCustomItem() { ItemsCount++; CustomBreadcrumbItemsWithCustomized.Add(new PageInfoModel() { Name = $"Item {ItemsCount}" }); } private void RemoveCustomItem() { if (CustomBreadcrumbItemsWithCustomized.Count > 1) { ItemsCount--; var item = CustomBreadcrumbItemsWithCustomized[^1]; CustomBreadcrumbItemsWithCustomized.Remove(item); if (item.IsCurrent) { CustomBreadcrumbItemsWithCustomized[^1].IsCurrent = true; } } } }
External Icons
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" /> <BitBreadcrumb Items="BreadcrumbItemsWithExternalIcon1" MaxDisplayedItems="3" OverflowIndex="2" Styles="@(new() { ItemIcon = "line-height:unset" })" /> <BitBreadcrumb Items="BreadcrumbItemsWithExternalIcon2" MaxDisplayedItems="3" OverflowIndex="2" Styles="@(new() { ItemIcon = "line-height:unset" })" /> <BitBreadcrumb Items="BreadcrumbItemsWithExternalIcon3" MaxDisplayedItems="3" OverflowIndex="2" Styles="@(new() { ItemIcon = "line-height:unset" })" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css" /> <BitBreadcrumb Items="BreadcrumbItemsWithExternalIcon4" MaxDisplayedItems="3" OverflowIndex="2" />@code { private readonly List<BitBreadcrumbItem> BreadcrumbItemsWithExternalIcon1 = [ new() { Text = "Home", Icon = "fa-solid fa-house" }, new() { Text = "Products", Icon = "fa-solid fa-box" }, new() { Text = "Electronics", Icon = "fa-solid fa-microchip" }, new() { Text = "Laptops", Icon = "fa-solid fa-laptop", IsSelected = true } ]; private readonly List<BitBreadcrumbItem> BreadcrumbItemsWithExternalIcon2 = [ new() { Text = "Home", Icon = BitIconInfo.Css("fa-solid fa-house") }, new() { Text = "Products", Icon = BitIconInfo.Css("fa-solid fa-box") }, new() { Text = "Electronics", Icon = BitIconInfo.Css("fa-solid fa-microchip") }, new() { Text = "Laptops", Icon = BitIconInfo.Css("fa-solid fa-laptop"), IsSelected = true } ]; private readonly List<BitBreadcrumbItem> BreadcrumbItemsWithExternalIcon3 = [ new() { Text = "Home", Icon = BitIconInfo.Fa("solid house") }, new() { Text = "Products", Icon = BitIconInfo.Fa("solid box") }, new() { Text = "Electronics", Icon = BitIconInfo.Fa("solid microchip") }, new() { Text = "Laptops", Icon = BitIconInfo.Fa("solid laptop"), IsSelected = true } ]; private readonly List<BitBreadcrumbItem> BreadcrumbItemsWithExternalIcon4 = [ new() { Text = "Home", Icon = BitIconInfo.Bi("house-fill") }, new() { Text = "Products", Icon = BitIconInfo.Bi("box-seam-fill") }, new() { Text = "Electronics", Icon = BitIconInfo.Bi("cpu-fill") }, new() { Text = "Laptops", Icon = BitIconInfo.Bi("laptop-fill"), IsSelected = true } ]; }
- Home
- Products
- Laptops
- Electronics
- Home
- Products
- Laptops
- Electronics
- Home
- Products
- Laptops
- Electronics
- Home
- Products
- Laptops
- Electronics
Class & Style
<style> .custom-class { font-style: italic; text-shadow: dodgerblue 0 0 0.5rem; border-bottom: 1px solid dodgerblue; } .custom-item { color: #ffcece; &:hover { color: #ff6868; background: transparent; } } .custom-item-1 { color: #b6ff00; &:hover { color: #2aff00; background: transparent; } } .custom-item-2 { color: #ffd800; &:hover { color: #ff6a00; background: transparent; } } .custom-selected-item { color: blueviolet; &:hover { color: blueviolet; background: transparent; text-shadow: blueviolet 0 0 1rem; } } </style> <BitBreadcrumb Items="BreadcrumbItems" Class="custom-class" /> <BitBreadcrumb Items="BreadcrumbItems" Style="font-style: italic;text-shadow: aqua 0 0 0.5rem;border-bottom: 1px solid aqua;" /> <BitBreadcrumb Items="BreadcrumbItemsWithClass" /> <BitBreadcrumb Items="BreadcrumbItemsWithStyle" /> <BitBreadcrumb Items="BreadcrumbItems" Classes="@(new() { Item = "custom-item", SelectedItem = "custom-selected-item" })" /> <BitBreadcrumb Items="BreadcrumbItems" Styles="@(new() { Item = "color: green;", SelectedItem = "color: lightseagreen; text-shadow: lightseagreen 0 0 1rem;" })" />@code { private readonly List<BitBreadcrumbItem> BreadcrumbItems = [ new() { Text = "Item 1", Href = "/components/breadcrumb" }, new() { Text = "Item 2", Href = "/components/breadcrumb" }, new() { Text = "Item 3", Href = "/components/breadcrumb" }, new() { Text = "Item 4", Href = "/components/breadcrumb", IsSelected = true } ]; private readonly List<BitBreadcrumbItem> BreadcrumbItemsWithClass = [ new() { Text = "Item 1", Href = "/components/breadcrumb", Class = "custom-item-1" }, new() { Text = "Item 2", Href = "/components/breadcrumb", Class = "custom-item-2" }, new() { Text = "Item 3", Href = "/components/breadcrumb", Class = "custom-item-1" }, new() { Text = "Item 4", Href = "/components/breadcrumb", Class = "custom-item-2", IsSelected = true } ]; private readonly List<BitBreadcrumbItem> BreadcrumbItemsWithStyle = [ new() { Text = "Item 1", Href = "/components/breadcrumb", Style = "color: dodgerblue; text-shadow: dodgerblue 0 0 1rem;" }, new() { Text = "Item 2", Href = "/components/breadcrumb", Style = "color: aqua; text-shadow: aqua 0 0 1rem;" }, new() { Text = "Item 3", Href = "/components/breadcrumb", Style = "color: dodgerblue; text-shadow: dodgerblue 0 0 1rem;" }, new() { Text = "Item 4", Href = "/components/breadcrumb", Style = "color: aqua; text-shadow: aqua 0 0 1rem;", IsSelected = true } ]; }
RTL
<BitBreadcrumb Dir="BitDir.Rtl" Items="RtlBreadcrumbItems" MaxDisplayedItems="3" OverflowIndex="2" />@code { private readonly List<BitBreadcrumbItem> RtlBreadcrumbItems = [ new() { Text = "پوشه اول" }, new() { Text = "پوشه دوم", IsSelected = true }, new() { Text = "پوشه سوم" }, new() { Text = "پوشه چهارم" }, new() { Text = "پوشه پنجم" }, new() { Text = "پوشه ششم" }, ]; }
- پوشه اول
- پوشه دوم
- پوشه ششم
- پوشه سوم
- پوشه چهارم
- پوشه پنجم
API
BitBreadcrumb parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| ChildContent | RenderFragment? | null | The content of the BitBreadcrumb, that are BitBreadOption components. |
| Classes | BitBreadcrumbClassStyles? | null | Custom CSS classes for different parts of the breadcrumb. |
| DividerIcon | BitIconInfo? | null | Render a custom divider icon in place of the default chevron. |
| DividerIconName | string? | null | The divider icon name. |
| DividerIconTemplate | RenderFragment? | null | The custom template content to render divider icon. |
| Items | IList<TItem> | [] | Collection of BreadLists to render. |
| ItemTemplate | RenderFragment<TItem>? | null | The custom template content to render each item. |
| MaxDisplayedItems | uint | 0 | The maximum number of breadcrumbs to display before coalescing. If not specified, all breadcrumbs will be rendered. |
| NameSelectors | BitBreadcrumbNameSelectors<TItem>? | null | Names and selectors of the custom input type properties. |
| OnItemClick | EventCallback<TItem> | Callback for when the breadcrumb item clicked. | |
| Options | RenderFragment? | null | Alias of the ChildContent. |
| OverflowAriaLabel | string? | null | Aria label for the overflow button. |
| OverflowIndex | uint | 0 | Optional index where overflow items will be collapsed. |
| OverflowIcon | BitIconInfo? | null | Render a custom overflow icon in place of the default icon. |
| OverflowIconName | string | More | The overflow icon name. |
| OverflowIconTemplate | RenderFragment? | null | The custom template content to render each overflow icon. |
| OverflowTemplate | RenderFragment<TItem>? | null | The custom template content to render each item in overflow list. |
| ReversedIcon | bool | false | Reverses the positions of the icon and the item text of the item content. |
| Styles | BitBreadcrumbClassStyles? | null | Custom CSS styles for different parts of the breadcrumb. |
BitComponentBase parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaLabel | string? | null | Gets or sets the accessible label for the component, used by assistive technologies. |
| Class | string? | null | Gets or sets the CSS class name(s) to apply to the rendered element. |
| Dir | BitDir? | null | Gets or sets the text directionality for the component's content. |
| ForceAnimation | bool | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. |
| HtmlAttributes | Dictionary<string, object> | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. |
| Id | string? | null | Gets or sets the unique identifier for the component's root element. |
| IsEnabled | bool | true | Gets or sets a value indicating whether the component is enabled and can respond to user interaction. |
| Style | string? | null | Gets or sets the CSS style string to apply to the rendered element. |
| TabIndex | string? | null | Gets or sets the tab order index for the component when navigating with the keyboard. |
| Visibility | BitVisibility | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. |
BitComponentBase public members
| Name | Type | Default value | Description |
|---|---|---|---|
| UniqueId | Guid | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. |
| RootElement | ElementReference | Gets the reference to the root HTML element associated with this component. |
BitBreadcrumbClassStyles properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the root element of the BitBreadcrumb. |
| Overlay | string? | null | Custom CSS classes/styles for the overlay of the BitBreadcrumb. |
| ItemContainer | string? | null | Custom CSS classes/styles for the item container of the BitBreadcrumb. |
| OverflowButton | string? | null | Custom CSS classes/styles for the overflow button of the BitBreadcrumb. |
| OverflowButtonIcon | string? | null | Custom CSS classes/styles for the overflow button icon of the BitBreadcrumb. |
| ItemWrapper | string? | null | Custom CSS classes/styles for the item wrapper of the BitBreadcrumb. |
| Item | string? | null | Custom CSS classes/styles for each item of the BitBreadcrumb. |
| ItemIcon | string? | null | Custom CSS classes/styles for each item icon of the BitBreadcrumb. |
| ItemText | string? | null | Custom CSS classes/styles for each item text of the BitBreadcrumb. |
| SelectedItem | string? | null | Custom CSS classes/styles for the selected item of the BitBreadcrumb. |
| Divider | string? | null | Custom CSS classes/styles for the divider of the BitBreadcrumb. |
| DividerIcon | string? | null | Custom CSS classes/styles for the divider icon of the BitBreadcrumb. |
| Callout | string? | null | Custom CSS classes/styles for the callout element of the BitBreadcrumb. |
| CalloutContainer | string? | null | Custom CSS classes/styles for the callout container of the BitBreadcrumb. |
| OverflowItemWrapper | string? | null | Custom CSS classes/styles for the overflow item wrapper of the BitBreadcrumb. |
| OverflowItem | string? | null | Custom CSS classes/styles for each overflow item of the BitBreadcrumb. |
| OverflowItemIcon | string? | null | Custom CSS classes/styles for each overflow item icon of the BitBreadcrumb. |
| OverflowItemText | string? | null | Custom CSS classes/styles for each overflow item text of the BitBreadcrumb. |
| OverflowSelectedItem | string? | null | Custom CSS classes/styles for the overflow selected item of the BitBreadcrumb. |
BitBreadcrumbNameSelectors<TItem> properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Key | BitNameSelectorPair<TItem, string?> | new(nameof(BitBreadcrumbItem.Key)) | The Id field name and selector of the custom input class. |
| Text | BitNameSelectorPair<TItem, string?> | new(nameof(BitBreadcrumbItem.Text)) | The Text field name and selector of the custom input class. |
| Href | BitNameSelectorPair<TItem, string?> | new(nameof(BitBreadcrumbItem.Href)) | The Href field name and selector of the custom input class. |
| Class | BitNameSelectorPair<TItem, string?> | new(nameof(BitBreadcrumbItem.Class)) | The CSS Class field name and selector of the custom input class. |
| Style | BitNameSelectorPair<TItem, string?> | new(nameof(BitBreadcrumbItem.Style)) | The CSS Style field name and selector of the custom input class. |
| Icon | BitNameSelectorPair<TItem, BitIconInfo?> | new(nameof(BitBreadcrumbItem.Icon)) | The Icon field name and selector of the custom input class. |
| IconName | BitNameSelectorPair<TItem, string?> | new(nameof(BitBreadcrumbItem.IconName)) | The IconName field name and selector of the custom input class. |
| ReversedIcon | BitNameSelectorPair<TItem, bool?> | new(nameof(BitBreadcrumbItem.ReversedIcon)) | The ReversedIcon field name and selector of the custom input class. |
| IsSelected | BitNameSelectorPair<TItem, bool> | new(nameof(BitBreadcrumbItem.IsSelected)) | The IsSelected field name and selector of the custom input class. |
| IsEnabled | BitNameSelectorPair<TItem, bool> | new(nameof(BitBreadcrumbItem.IsEnabled)) | The IsEnabled field name and selector of the custom input class. |
| OnClick | Action<TItem>? | Click event handler of the item. | |
| OverflowTemplate | BitNameSelectorPair<TItem, RenderFragment<TItem>?> | new(nameof(BitBreadcrumbItem.OverflowTemplate)) | The OverflowTemplate field name and selector of the custom input class. |
| Template | BitNameSelectorPair<TItem, RenderFragment<TItem>?> | new(nameof(BitBreadcrumbItem.Template)) | The Template field name and selector of the custom input class. |
BitNameSelectorPair<TItem, TProp> properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Name | string | Custom class property name. | |
| Selector | Func<TItem, TProp?>? | Custom class property selector. |
BitIconInfo properties
Represents icon information for rendering icons. Supports built-in Fluent UI icons and external icon libraries (FontAwesome, Bootstrap Icons, etc.). Use BitIconInfo.Css("fa-solid fa-star"), BitIconInfo.Fa("solid star"), or BitIconInfo.Bi("star-fill") for external icons.
| Name | Type | Default value | Description |
|---|---|---|---|
| Name | string? | null | Gets or sets the name of the icon. For external icons, this can be the full CSS class name if BaseClass and Prefix are empty. |
| BaseClass | string? | null | Gets or sets the base CSS class for the icon. For built-in Fluent UI icons, this defaults to "bit-icon". For external icon libraries like FontAwesome, you might set this to "fa" or leave empty. |
| Prefix | string? | null | Gets or sets the CSS class prefix used before the icon name. For built-in Fluent UI icons, this defaults to "bit-icon--". For external icon libraries, you might set this to "fa-" or leave empty. |
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.