UI Patterns

Full screen navigationStatusrelease

Show and hide full screen navigation.

Guidance

Use this pattern for navigation that take over the whole screen and prevent interaction with the rest of the page until it is closed.

This pattern differs from a modal dialog because it is CSS-based and does not require being marked up as a dialog. This is useful if you want the same nav mark up used as both inline navigation (visible on large screens) and off-canvas or modal-like navigation on small screens.

When the full screen menu is open, it shouldn't be possible for the user to access the content beneath via mouse, keyboard or other means. At the time of writing, the most cross-device compatible way to achieve this is by setting all other elements to display: none !important;visibility: hidden !important; in CSS using the toggle classes provided on the body tag.

Example

Open in a new tab

Dependencies and installation

PackageInstallation
@stormid/toggle
npm i -S @stormid/toggle

Code

<nav aria-label="Primary navigation"><button type="button" class="full-screen-nav__btn js-full-screen-nav__toggle" aria-label="Open menu" aria-controls="full-screen-navigation" aria-expanded="false"><svg focusable="false" class="full-screen-nav__btn-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"></path><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"></path></svg>menu</button><div id="full-screen-navigation" class="js-full-screen-nav full-screen-nav" data-toggle="js-full-screen-nav__toggle"><ul class="wrap full-screen-nav__list"><li class="full-screen-nav__item"><a class="full-screen-nav__link" href="#">Item 1</a></li><li class="full-screen-nav__item"><a class="full-screen-nav__link is--active" href="#" aria-current="page">Item 2</a></li><li class="full-screen-nav__item"><a class="full-screen-nav__link" href="#">Item 3</a></li><li class="full-screen-nav__item"><a class="full-screen-nav__link" href="#">Item 4</a></li><li class="full-screen-nav__item"><a class="full-screen-nav__link" href="#">Item 5</a></li></ul><button type="button" class="full-screen-navigation__close js-full-screen-nav__toggle" aria-label="Close menu">close</button></div></nav>
import toggle from '@stormid/toggle';

toggle('.js-full-screen-navigation');

Acceptance criteria

The following is a list of example acceptance criteria to test against when using this pattern. These critera should test that the specific markup requirements are met, and that the navigation behaves visually and functionally as expected.

For validation in developer tools / web inspector

For visual validation

For functional validation

References