Skip to main content

Exit

Emergency exit button for sensitive content sites. Navigates the user to a safe URL and cloaks the current page. Works as a plain link without JavaScript; with JavaScript it adds page cloaking, scripted navigation, and a triple-Escape keyboard shortcut (on by default, turned off document-wide by data-exit-no-esc).

Why an <a> and not a <button>? This is a safety-critical component that must still take the user to safety when JavaScript is blocked, disabled, or fails to load. A <button> cannot navigate without JS, but a plain <a href> always works. The JS then enhances the link by intercepting the click to cloak the page before navigation. Progressive enhancement is non-negotiable here: a user fleeing an unsafe situation cannot be stranded by a script error.

Usage​

When to use

  • Sites covering sensitive topics where a visitor may need to leave the page suddenly
  • Any page where a visible "leave now" affordance improves visitor safety

When not to use

  • General-purpose sites with no safety concern
  • As a replacement for a back button or normal navigation

Do

  • Keep the exit control sticky and visible on every page
  • Provide instructional text next to the button explaining what it does
  • Make sure the control works without JavaScript as a plain link

Don't

  • Remove focus indicators from the exit control
  • Overlap the exit control with a back-to-top button
  • Rely on JavaScript alone - the no-JS fallback must still take the user to safety

API​

Slots​

SlotRequiredDescription
text-Instructional text next to the button.
labelYesButton text.

Props​

PropTypeDefaultDescription
urlstring-Safe URL the user is sent to.
text_idstring-id for the instructional text element, referenced by aria-describedby. Defaults to "exit-text" when omitted.
is_escape_shortcut_disabledboolean-Opts out of the triple-Escape keyboard shortcut.
classesarray-Additional CSS class words merged into the root element.
attributesobject-Additional HTML attributes spread on the root element.

Classes​

ClassCapabilityDefaultDescription
.smSize-Small.
.mdSizeYesMedium.
.lgSize-Large.
.topAlignment-Anchored to the top.
.bottomAlignment-Anchored to the bottom.
.animatedMotionYesHonors the animations option.
.stillMotion-Forces motion off regardless of the option.
.flatElevationYesNo elevation.
.raisedElevation-Slight elevation.

Attributes​

AttributeSet byRequiredDescription
data-exit-urlConsumer-Safe URL the exit button navigates to. The JS reads this when handling the triple-Escape shortcut and the scripted click path.
data-exit-no-escConsumer-Turns the triple-Escape keyboard shortcut off for the whole document. The shortcut is on by default, so one instance carrying this attribute suppresses it for every instance on the page.
data-exit-cloakedScript-Present on the document root while an exit navigation is in flight; the component CSS hides the page while it is set.

Examples​

Bottom​

Exit button positioned at the bottom of the viewport.

No escape shortcut​

Triple-Escape shortcut is on by default. This variant turns it off via data-exit-no-esc. The shortcut is a single document-wide key binding, so one instance carrying the attribute suppresses it for every instance on the page - including the examples above.

No JS fallback​

Plain <a> fallback behavior with JavaScript disabled.

Accessibility​

  • WCAG 2.2 AA
  • Keyboard accessible and included in the tab order
  • Instructional text programmatically associated with the button
  • Clear focus indicators that must not be removed
  • Works without JavaScript as a plain link
  • Supports zoom up to 400% without loss of functionality

Progressive enhancement​

  • No JS: plain <a> that navigates to the safe URL
  • With JS: page cloaking before navigation, triple-Escape keyboard shortcut (on by default; turn it off with data-exit-no-esc on any exit instance in the document), and scripted navigation to the safe URL. The redirect must be atomic: set display: none on <html> and immediately call location.replace(safeUrl). A short failsafe timeout (1500ms) uncloaks the document and returns focus to the exit button if navigation does not proceed, so users are never stranded on a blank page.
  • How to enable: include the exit script and set data-exit-url (and optionally data-exit-no-esc) on the exit element
  • back-to-top - another sticky control; must not overlap exit