Skip to main content
Components

Exit this page

Give users a way to quickly and safely exit a service, website or application.

Once JavaScript runs, the button, a SkipLink, or pressing Shift 3 times hides the page and goes to the button's href, as in govuk-frontend.

Read the Design System guidance for exit this page

Import

import * as ExitThisPage from 'govuk-react/exit-this-page';

Examples

Default

Code
<ExitThisPage.Composite />
Code
<>
  <ExitThisPage.SkipLink>Exit this page</ExitThisPage.SkipLink>
  <Body>Press Tab to show the skip link, which exits the page too.</Body>
  <ExitThisPage.Composite {...args} />
</>

Shift pressed once

Code
<>
  <Body>Shift has been pressed once in this example. This is for visual regression testing.</Body>
  <ExitThisPage.Composite {...args} />
  <PressShiftOnce />
</>

API reference

ExitThisPage.Root

Give users a way to quickly and safely exit a service, website or application.

Once JavaScript runs, the button, a SkipLink, or pressing Shift 3 times hides the page and goes to the button's href, as in govuk-frontend.

PropType
activatedText

Text announced by screen readers when Exit this Page has been activated via the keyboard shortcut. Defaults to "Loading.".

string
timedOutText

Text announced by screen readers when the keyboard shortcut has timed out without successful activation. Defaults to "Exit this page expired.".

string
pressTwoMoreTimesText

Text announced by screen readers when the user must press <kbd>Shift</kbd> two more times to activate the button. Defaults to "Shift, press 2 more times to exit.".

string
pressOneMoreTimeText

Text announced by screen readers when the user must press <kbd>Shift</kbd> one more time to activate the button. Defaults to "Shift, press 1 more time to exit.".

string

ExitThisPage.Button

The link to a safe page. Shows how many times Shift has been pressed.

PropType
classNamestring
asundefined
preventDoubleClick

Prevent accidental double clicks on submit buttons from submitting forms multiple times. This has no effect if href is set.

boolean
hrefstring

ExitThisPage.Composite

Give users a way to quickly and safely exit a service, website or application.

Once JavaScript runs, the button, a SkipLink, or pressing Shift 3 times hides the page and goes to the button's href, as in govuk-frontend.

PropType
activatedText

Text announced by screen readers when Exit this Page has been activated via the keyboard shortcut. Defaults to "Loading.".

string
timedOutText

Text announced by screen readers when the keyboard shortcut has timed out without successful activation. Defaults to "Exit this page expired.".

string
pressTwoMoreTimesText

Text announced by screen readers when the user must press <kbd>Shift</kbd> two more times to activate the button. Defaults to "Shift, press 2 more times to exit.".

string
pressOneMoreTimeText

Text announced by screen readers when the user must press <kbd>Shift</kbd> one more time to activate the button. Defaults to "Shift, press 1 more time to exit.".

string
hrefstring

ExitThisPage.Indicator

Shows how many times Shift has been pressed. Button renders it.

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

A skip link that exits the page too, for the top of the page.

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

ExitThisPage.Status

Tells screen readers how many more presses are needed. Root renders it.

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