Example of Keyboard Navigation in ASP.NET MVC Breadcrumb Control
This sample demonstrates the keyboard navigation functionalities of the Breadcrumb component.
Simple Breadcrumb
@Html.UiButton(new UiButtonOptions { Id = "reset", Text = "Reset State", Size = UiInputSize.Small })
@Html.UiBreadcrumb(new UiBreadcrumbOptions { Id = "keyboard-navigation", OnItemClick = "noNavigation", BindToLocation = true })
<style>
.content-wrapper { width: 90%; margin: 0 auto; min-width: 85px; }
.content-wrapper div.row { padding: 15px 0px; }
#reset { float: right; margin: 5px 2px 5px 0; }
.content-wrapper {
width: 90%;
margin: 0 auto;
min-width: 85px;
}
.content-wrapper div.row {
padding: 15px 0px;
}
</style>
<div class="control-section">
<div class="content-wrapper">
<div class="row material2">
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12">
<h5 style="display: inline-block">Simple Breadcrumb</h5>
@Html.UiButton(new UiButtonOptions { Id = "reset", Text = "Reset State", Size = UiInputSize.Small })
</div>
</div>
<div class="row material2">
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12">
@Html.UiBreadcrumb(new UiBreadcrumbOptions { Id = "keyboard-navigation", OnItemClick = "noNavigation", BindToLocation = true })
</div>
</div>
</div>
</div>
<script>
// Syncfusion: Reset State sets every Breadcrumb of the page back as it was first drawn
document.getElementById('reset').addEventListener('click', function () {
document.querySelectorAll('.content-wrapper .ui-breadcrumb').forEach(function (breadcrumb) { window.Lumen.get(breadcrumb.id).reset(); });
});
// Syncfusion: enableNavigation is false, so a click on an item only raises the event
function noNavigation() { return false; }
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class BreadcrumbController : Controller
{
// The page is Views/Breadcrumb/KeyboardNavigation.cshtml; it draws what ViewData holds.
public ActionResult KeyboardNavigation()
{
return View();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
The Breadcrumb component can be interacted with keyboard navigation. Below key combinations can be used in Breadcrumb to initiate various actions.
- Tab to navigate to the next item.
- Shift + Tab to navigate to the previous item.
- Enter to click the item.