Service navigation
Read more about the
service navigation
component on the Gov.UK Design System website
@using GovUkDesignSystemDotNet
@await Html.GovUkServiceNavigation(new ServiceNavigationViewModel
{
NavigationItems = new List<ServiceNavigationItemViewModel>
{
new ServiceNavigationItemViewModel
{
Href = "#",
HtmlOrText = new HtmlOrText("Navigation item 1"),
},
new ServiceNavigationItemViewModel
{
Href = "#",
HtmlOrText = new HtmlOrText("Navigation item 2"),
Active = true
},
new ServiceNavigationItemViewModel
{
Href = "#",
HtmlOrText = new HtmlOrText("Navigation item 3"),
},
}
})
Options
Options for ServiceNavigationViewModel
|
List<string>
|
Classes to add to the service navigation container.
|
|
Dictionary<string, string>
|
HTML attributes (for example, data attributes) to add to the service navigation container.
|
|
string
|
The text for the aria-label which labels the
service navigation container when a service name is included.
Defaults to "Service information".
|
|
string
|
The text of the mobile navigation menu toggle.
Defaults to "Menu".
|
|
string
|
The screen reader label for the mobile navigation menu toggle.
Defaults to the same value as MenuButtonText if not specified.
|
|
string
|
The screen reader label for the mobile navigation menu.
Defaults to the same value as MenuButtonText if not specified.
|
|
string
|
The ID used to associate the mobile navigation toggle with the navigation menu.
Defaults to navigation.
|
|
string
|
Classes to add to the navigation menu container.
|
|
bool?
|
Whether the navigation should be collapsed inside a menu on mobile.
Defaults to true if there is more than one navigation item.
|
|
string
|
The name of your service.
|
|
string
|
The homepage of your service.
|
|
List<ServiceNavigationItemViewModel>
|
Required.
Used to add navigation to the service header.
See options for ServiceNavigationItemViewModel
|
|
ServiceNavigationSlotsViewModel
|
Specified points for injecting custom HTML into the service header.
See options for ServiceNavigationSlotsViewModel
|
Options for ServiceNavigationItemViewModel
|
bool
|
If true, indicates that the user is currently on this page.
This takes precedence over Active.
|
|
bool
|
If true, indicates that the user is within this group of pages in the navigation hierarchy.
|
|
HtmlOrText
|
Required.
HTML or text for the navigation item.
|
|
string
|
URL of the navigation item anchor.
|
|
Dictionary<string, string>
|
HTML attributes (for example data attributes) to add to the navigation item anchor.
|
Options for ServiceNavigationSlotsViewModel
|
HtmlOrText
|
HTML injected at the start of the service header container.
|
|
HtmlOrText
|
HTML injected at the end of the service header container.
|
|
HtmlOrText
|
HTML injected before the first list item in the navigation list.
Requires NavigationItems to be set.
|
|
HtmlOrText
|
HTML injected after the last list item in the navigation list.
Requires NavigationItems to be set.
|
Examples
Alongside the GOV.UK Header
See more details about the
header component
@using GovUkDesignSystemDotNet
@await Html.GovUkHeader(new HeaderViewModel
{
HomepageUrl = "#"
})
@await Html.GovUkServiceNavigation(new ServiceNavigationViewModel
{
NavigationItems = new List<ServiceNavigationItemViewModel>
{
new ServiceNavigationItemViewModel
{
Href = "#",
HtmlOrText = new HtmlOrText("Navigation item 1"),
},
new ServiceNavigationItemViewModel
{
Href = "#",
HtmlOrText = new HtmlOrText("Navigation item 2"),
Active = true
},
new ServiceNavigationItemViewModel
{
Href = "#",
HtmlOrText = new HtmlOrText("Navigation item 3"),
},
}
})
Showing service name and navigation links
@using GovUkDesignSystemDotNet
@await Html.GovUkServiceNavigation(new ServiceNavigationViewModel
{
ServiceName = "Design System in C#",
ServiceUrl = "#",
NavigationItems = new List<ServiceNavigationItemViewModel>
{
new ServiceNavigationItemViewModel
{
Href = "#",
HtmlOrText = new HtmlOrText("Navigation item 1"),
},
new ServiceNavigationItemViewModel
{
Href = "#",
HtmlOrText = new HtmlOrText("Navigation item 2"),
Active = true
},
new ServiceNavigationItemViewModel
{
Href = "#",
HtmlOrText = new HtmlOrText("Navigation item 3"),
},
}
})