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
| Slot | Required | Description |
|---|---|---|
text | - | Instructional text next to the button. |
label | Yes | Button text. |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
url | string | - | Safe URL the user is sent to. |
text_id | string | - | id for the instructional text element, referenced by aria-describedby. Defaults to "exit-text" when omitted. |
is_escape_shortcut_disabled | boolean | - | Opts out of the triple-Escape keyboard shortcut. |
classes | array | - | Additional CSS class words merged into the root element. |
attributes | object | - | Additional HTML attributes spread on the root element. |
Classes
| Class | Capability | Default | Description |
|---|---|---|---|
.sm | Size | - | Small. |
.md | Size | Yes | Medium. |
.lg | Size | - | Large. |
.top | Alignment | - | Anchored to the top. |
.bottom | Alignment | - | Anchored to the bottom. |
.animated | Motion | Yes | Honors the animations option. |
.still | Motion | - | Forces motion off regardless of the option. |
.flat | Elevation | Yes | No elevation. |
.raised | Elevation | - | Slight elevation. |
Attributes
| Attribute | Set by | Required | Description |
|---|---|---|---|
data-exit-url | Consumer | - | 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-esc | Consumer | - | 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-cloaked | Script | - | 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-escon any exit instance in the document), and scripted navigation to the safe URL. The redirect must be atomic: setdisplay: noneon<html>and immediately calllocation.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 optionallydata-exit-no-esc) on the exit element
Related
- back-to-top - another sticky control; must not overlap exit