Skip to main content
Components

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.

PropType
as"div" | "section"
inverseboolean

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.

PropType
as"div" | "section"
inverseboolean
serviceName

The name of your service.

ReactNode
serviceHref

The homepage of your service.

string
navigationLabel

The screen reader label for the mobile navigation menu. Defaults to the same value as menuButtonText if not specified.

string
menuButtonText

The text of the mobile navigation menu toggle.

string
collapseNavigationOnMobile

Whether the navigation should be collapsed inside a menu on mobile. Defaults to true if there is more than one navigation item.

boolean
items

Prefer children, which memoise and re-render better.

ItemCompositeProps[]
open

Whether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating.

boolean
onOpenChange

Called 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.

PropType
as"div" | "section"
inverseboolean
serviceName

The name of your service.

ReactNode
serviceHref

The homepage of your service.

string
navigationLabel

The screen reader label for the mobile navigation menu. Defaults to the same value as menuButtonText if not specified.

string
menuButtonText

The text of the mobile navigation menu toggle.

string
collapseNavigationOnMobile

Whether the navigation should be collapsed inside a menu on mobile. Defaults to true if there is more than one navigation item.

boolean
items

Prefer children, which memoise and re-render better.

ItemCompositeProps[]
open

Whether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating.

boolean
onOpenChange

Called 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.

PropType
open

Whether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating.

boolean
onOpenChange

Called when the user opens or closes the menu.

(open: boolean, details: ChangeDetails) => void

ServiceNavigation.Item

PropType
activeboolean

ServiceNavigation.ItemComposite

PropType
active

If true, indicates that the user is within this group of pages in the navigation hierarchy.

boolean
href

URL of the navigation item anchor.

string
current

If true, indicates that the user is currently on this page. This takes precedence over active.

boolean
PropType
asChild

Render the only child (such as a router's link) instead of an a, with the link classes merged onto it.

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.

PropType
open

Whether 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
onOpenChange

Called 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

PropType
inlineEndSlotboolean

ServiceNavigation.Wrapper

No props of its own. Other props are passed to the element it renders.