Component
Sub navigation menu (experimental)
The sub navigation menu component helps users to navigate pages within a section of GOV.UK
Overview
How it looks (preview) (preview all)
How to call this component
<%= render "govuk_publishing_components/components/sub_navigation_menu", {
links: [
{
text: "Example Heading",
links: [
{
text: "Hello world",
href: "/hello-world"
}
]
},
{
text: "Another Heading",
links: [
{
text: "Example Link",
href: "/hello-world"
},
{
text: "Example Link 2",
href: "/hello-world"
},
{
text: "Example Link 3",
href: "/hello-world"
},
{
text: "This is a very very very long link",
href: "/hello-world"
},
{
text: "Another link that has a lot of characters",
href: "/hello-world"
},
{
text: "Third link containing a lot of text",
href: "/hello-world"
}
]
}
]
} %>
Accessibility acceptance criteria
The menu component must:
- be recognisable as navigation
- have the correct heading level structure
- indicate that any expandable content can be expanded or collapsed
- indicate the initial state of expandable content
- indicate where the state of expandable content has changed
When CSS and / or JavaScript is unavailable, the component must:
- fallback to an expanded menu
Links in the component must:
- accept focus
- be focusable with a keyboard
- be usable with a keyboard
- indicate when they have focus
- change in appearance when touched (in the touch-down state)
- change in appearance when hovered
- be usable with touch
- be usable with voice commands
- have visible text
- have meaningful text
Other examples
Standard options
This component uses the component wrapper helper. It accepts the following options and applies them to the parent element of the component. See the component wrapper helper documentation for more detail.
See all standard options
id- accepts a string for the element ID attributedata_attributes- accepts a hash of data attributesaria- accepts a hash of aria attributesclasses- accepts a space separated string of classes, these should not be used for styling and must be prefixed withjs-margin_bottom- accepts a number from0to9(0pxto60px) using the GOV.UK Frontend spacing scalerole- accepts a space separated string of roleslang- accepts a language attribute valueopen- accepts an open attribute value (true or false)hidden- accepts an empty string, ‘hidden’, or ‘until-found’tabindex- accepts an integer. The integer can also be passed as a stringdir- accepts ‘rtl’, ‘ltr’, or ‘auto’type- accepts any valid type attribute e.g. ‘button’, ‘submit’, ‘text’rel- accepts any valid rel attribute e.g. ‘nofollow’target- accepts a valid target attribute e.g. ‘_blank’title- accepts any stringdraggable- accepts a draggable attribute value (“true” or “false”)
Custom button text (preview)
<%= render "govuk_publishing_components/components/sub_navigation_menu", {
button_text: "Open me",
links: [
{
text: "Example Heading",
links: [
{
text: "Hello world",
href: "/hello-world"
}
]
},
{
text: "Another Heading",
links: [
{
text: "Example Link",
href: "/hello-world"
}
]
}
]
} %>
Negative margin left on button (preview)
The button does not look perfectly aligned with the content by default, so this negative margin aligns the button chevron with the content.
<%= render "govuk_publishing_components/components/sub_navigation_menu", {
negative_margin_left_on_button: true,
links: [
{
text: "Example Heading",
links: [
{
text: "Hello world",
href: "/hello-world"
}
]
},
{
text: "Another Heading",
links: [
{
text: "Example Link",
href: "/hello-world"
}
]
}
]
} %>