Service navigation
Service navigation helps users understand that they’re using your service and lets them navigate around your service.
Children are ItemComposites. The menu is govuk-frontend's: without JavaScript the
navigation is always shown.
Read the Design System guidance for service navigation
Import
import * as ServiceNavigation from 'govuk-react/service-navigation';Examples
Default
Code
<ServiceNavigation.Composite>
<ServiceNavigation.ItemComposite href="#">Navigation item 1</ServiceNavigation.ItemComposite>
<ServiceNavigation.ItemComposite href="#" active>
Navigation item 2
</ServiceNavigation.ItemComposite>
<ServiceNavigation.ItemComposite href="#">Navigation item 3</ServiceNavigation.ItemComposite>
</ServiceNavigation.Composite>With parts
Code
<ServiceNavigation.Root as="section">
<ServiceNavigation.WidthContainer>
<ServiceNavigation.Container>
<ServiceNavigation.ServiceName>
<ServiceNavigation.Link href="#">Service name</ServiceNavigation.Link>
</ServiceNavigation.ServiceName>
<ServiceNavigation.Wrapper>
<ServiceNavigation.Menu>
<ServiceNavigation.Toggle />
<ServiceNavigation.List>
<ServiceNavigation.Item>
<ServiceNavigation.Link href="#">Navigation item 1</ServiceNavigation.Link>
</ServiceNavigation.Item>
<ServiceNavigation.Item active>
<ServiceNavigation.Link href="#">
<ServiceNavigation.ActiveFallback>Navigation item 2</ServiceNavigation.ActiveFallback>
</ServiceNavigation.Link>
</ServiceNavigation.Item>
<ServiceNavigation.Item>
<ServiceNavigation.Link href="#">Navigation item 3</ServiceNavigation.Link>
</ServiceNavigation.Item>
</ServiceNavigation.List>
</ServiceNavigation.Menu>
</ServiceNavigation.Wrapper>
</ServiceNavigation.Container>
</ServiceNavigation.WidthContainer>
</ServiceNavigation.Root>Controlled
Below tablet width, choosing a link closes the menu, as a single-page app would after navigating.
Code
<ServiceNavigation.Composite />Menu open
The menu open, below tablet width.
Code
<ServiceNavigation.Composite serviceName="Service name" serviceHref="#" open>
<ServiceNavigation.ItemComposite href="#">Navigation item 1</ServiceNavigation.ItemComposite>
<ServiceNavigation.ItemComposite href="#" current>
Navigation item 2
</ServiceNavigation.ItemComposite>
<ServiceNavigation.ItemComposite href="#">Navigation item 3</ServiceNavigation.ItemComposite>
</ServiceNavigation.Composite>Details
A menu that works without JavaScript, through a native details.
Code
<ServiceNavigation.DetailsComposite serviceName="Service name" serviceHref="#">
<ServiceNavigation.ItemComposite href="#">Navigation item 1</ServiceNavigation.ItemComposite>
<ServiceNavigation.ItemComposite href="#" current>
Navigation item 2
</ServiceNavigation.ItemComposite>
<ServiceNavigation.ItemComposite href="#">Navigation item 3</ServiceNavigation.ItemComposite>
</ServiceNavigation.DetailsComposite>Details open
The details menu open, below tablet width.
Code
<ServiceNavigation.DetailsComposite serviceName="Service name" serviceHref="#" open>
<ServiceNavigation.ItemComposite href="#">Navigation item 1</ServiceNavigation.ItemComposite>
<ServiceNavigation.ItemComposite href="#" current>
Navigation item 2
</ServiceNavigation.ItemComposite>
<ServiceNavigation.ItemComposite href="#">Navigation item 3</ServiceNavigation.ItemComposite>
</ServiceNavigation.DetailsComposite>Details with parts
Code
<ServiceNavigation.Root as="section">
<ServiceNavigation.WidthContainer>
<ServiceNavigation.Container>
<ServiceNavigation.ServiceName>
<ServiceNavigation.Link href="#">Service name</ServiceNavigation.Link>
</ServiceNavigation.ServiceName>
<ServiceNavigation.Wrapper>
<ServiceNavigation.DetailsMenu>
<ServiceNavigation.Summary />
<ServiceNavigation.List>
<ServiceNavigation.ItemComposite href="#">Navigation item 1</ServiceNavigation.ItemComposite>
<ServiceNavigation.ItemComposite href="#" current>
Navigation item 2
</ServiceNavigation.ItemComposite>
</ServiceNavigation.List>
</ServiceNavigation.DetailsMenu>
</ServiceNavigation.Wrapper>
</ServiceNavigation.Container>
</ServiceNavigation.WidthContainer>
</ServiceNavigation.Root>API reference
ServiceNavigation.Root
Service navigation helps users understand that they’re using your service and lets them navigate around your service.
| Prop | Type |
|---|---|
as | "div" | "section" |
inverse | boolean |
ServiceNavigation.ActiveFallback
No props of its own. Other props are passed to the element it renders.
ServiceNavigation.Composite
Service navigation helps users understand that they’re using your service and lets them navigate around your service.
Children are ItemComposites. The menu is govuk-frontend's: without JavaScript the
navigation is always shown.
| Prop | Type |
|---|---|
as | "div" | "section" |
inverse | boolean |
serviceNameThe name of your service. | ReactNode |
serviceHrefThe homepage of your service. | string |
navigationLabelThe screen reader label for the mobile navigation menu. Defaults to the same value as | string |
menuButtonTextThe text of the mobile navigation menu toggle. | string |
collapseNavigationOnMobileWhether the navigation should be collapsed inside a menu on mobile. Defaults to true if there is more than one navigation item. | boolean |
itemsPrefer children, which memoise and re-render better. | ItemCompositeProps[] |
openWhether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating. | boolean |
onOpenChangeCalled when the user opens or closes the menu. | (open: boolean, details: ChangeDetails) => void |
ServiceNavigation.Container
No props of its own. Other props are passed to the element it renders.
ServiceNavigation.DetailsComposite
Service navigation helps users understand that they’re using your service and lets them navigate around your service.
Children are ItemComposites. The menu is a DetailsMenu, which works without JavaScript but
has screen reader and voice control caveats: see DetailsMenu.
| Prop | Type |
|---|---|
as | "div" | "section" |
inverse | boolean |
serviceNameThe name of your service. | ReactNode |
serviceHrefThe homepage of your service. | string |
navigationLabelThe screen reader label for the mobile navigation menu. Defaults to the same value as | string |
menuButtonTextThe text of the mobile navigation menu toggle. | string |
collapseNavigationOnMobileWhether the navigation should be collapsed inside a menu on mobile. Defaults to true if there is more than one navigation item. | boolean |
itemsPrefer children, which memoise and re-render better. | ItemCompositeProps[] |
openWhether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating. | boolean |
onOpenChangeCalled when the user opens or closes the menu. | (open: boolean, details: ChangeDetails) => void |
ServiceNavigation.DetailsMenu
A menu that works without JavaScript: a native details, inside Wrapper, around Summary
and List. Below tablet width the summary shows and hides the list. From tablet width the list
shows where the browser supports ::details-content (Chrome and Edge 131, Safari 18.4,
Firefox 143), and stays behind the menu where it doesn't.
Check it with your users' assistive technology before choosing it over Menu. GOV.UK's audits
of the Details component found VoiceOver doesn't convey a summary's state on iOS before 17,
and Dragon voice control can have trouble opening one.
| Prop | Type |
|---|---|
openWhether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating. | boolean |
onOpenChangeCalled when the user opens or closes the menu. | (open: boolean, details: ChangeDetails) => void |
ServiceNavigation.Item
| Prop | Type |
|---|---|
active | boolean |
ServiceNavigation.ItemComposite
| Prop | Type |
|---|---|
activeIf | boolean |
hrefURL of the navigation item anchor. | string |
currentIf | boolean |
ServiceNavigation.Link
| Prop | Type |
|---|---|
asChildRender the only child (such as a router's link) instead of an | boolean |
ServiceNavigation.List
The navigation list, inside Menu or DetailsMenu, or straight inside Wrapper with no menu.
No props of its own. Other props are passed to the element it renders.
ServiceNavigation.Menu
govuk-frontend's menu: inside Wrapper, around Toggle and List. Below tablet width the
button shows and hides the list once JavaScript runs. Without JavaScript the list is always
shown and the button hidden.
| Prop | Type |
|---|---|
openWhether the content is shown, to control it once hydrated. Whether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating. | boolean |
onOpenChangeCalled when the user shows or hides the content. Called when the user opens or closes the menu. | ((open: boolean, details: ChangeDetails) => void) & ((open: boolean, details: ChangeDetails) => void) |
ServiceNavigation.ServiceName
No props of its own. Other props are passed to the element it renders.
ServiceNavigation.Summary
The menu button of DetailsMenu. Hidden from tablet width up, where the browser can show the list.
No props of its own. Other props are passed to the element it renders.
ServiceNavigation.Text
No props of its own. Other props are passed to the element it renders.
ServiceNavigation.Toggle
The menu button, inside Menu. Hidden from tablet width up, and without JavaScript.
No props of its own. Other props are passed to the element it renders.
ServiceNavigation.WidthContainer
| Prop | Type |
|---|---|
inlineEndSlot | boolean |
ServiceNavigation.Wrapper
No props of its own. Other props are passed to the element it renders.