Do Not Close

Do Not Close is a copy-paste React component that stops closed the tab mid-payment before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/do-not-close
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsClosed the tab mid-payment

Was this component page useful?

How do I install Do Not Close?

pnpm dlx shadcn@latest add @bollard/do-not-close

The files land in your project. They're yours to edit.

How do I use Do Not Close in React?

do-not-close-usage.tsx
import { DoNotClose, type OperationStatus } from "@/components/ui/do-not-close"

<DoNotClose
  status={status}
  progress={progress}
  label="Uploading 312 invoices (48 MB)"
  doneLabel="All 312 invoices uploaded"
  error="The connection dropped. Retry uploads only the invoices that are missing."
  onRetry={start}
/>

What input mistakes does Do Not Close catch?

  • Closing or reloading the tab while work is running (beforeunload warning)
  • Unclear progress, with a rolling-rate time-left estimate and a stalled notice
  • Uncertainty at the end, with an explicit "Safe to close"
  • Failures, with a Retry

What props does Do Not Close accept?

DoNotClose props
PropTypeDefault
status* (required)

`active` while the operation runs. `idle` renders nothing.

OperationStatus—
progress

0 to 1. Leave undefined when progress is unknown.

number—
label* (required)

What is happening, e.g. "Processing your payment".

string—
doneLabel

Shown when finished, e.g. "Payment confirmed".

string"All done"
error

What went wrong, shown in the `error` state.

string—
onRetry

Shows a Retry action in the `error` state.

() => void—
activeTitle

Headlines per state; `{label}` is filled in.

string"Don't close or refresh this tab"
doneTitle

Heading shown when it is safe to close.

string"Safe to close"
errorTitle

Heading shown when the work failed.

string"{label} didn't finish"
retryLabel

Retry button text.

string"Retry"
stalledText

Shown when progress has stalled.

string"taking longer than usual"
estimatingText

Shown while the time left is being estimated.

string"estimating time left"
titlePrefix

Prefix added to the tab title while active.

string"⏳ Don't close · "
doneTitlePrefix

Prefix shown in the tab title when it finished while the user was in another tab.

string"✓ Safe to close · "
etaWindow

Rolling window for the time-left estimate, in ms.

number8000

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Do Not Close accessible?

  • role="progressbar" with aria-valuenow and an aria-valuetext including time left
  • Status in a role="status" region; failures use role="alert"
  • Retry is a labelled button

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Make long operations resumable or idempotent on the server, so a closed tab or retry doesn't leave work half done or duplicated.

  • Browsers decide whether to show the close warning and use their own text; mobile browsers often skip it
  • Can't prevent a crash, power loss or the OS killing the tab

What expensive mistakes does Do Not Close stop?

Closed the tab mid-payment

Also known as

do not close · beforeunload · payment processing · upload progress · migration · do not refresh · do not press back · time left

Field type

What dependencies does Do Not Close require?

Do Not Close facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameDo Not Close
Registry identifier@bollard/do-not-close
Install commandnpx shadcn@latest add @bollard/do-not-close
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Do Not Close

How does Do Not Close prevent financial transaction errors?

Do Not Close prevents closed the tab mid-payment. Blocks Closing or reloading the tab while work is running (beforeunload warning), Unclear progress, with a rolling-rate time-left estimate and a stalled notice, Uncertainty at the end, with an explicit "Safe to close", Failures, with a Retry before processing. Limitation: apply idempotency keys for do-not-close.

How do I install do-not-close with shadcn?

Run `npx shadcn@latest add @bollard/do-not-close`. Sources added: registry/default/do-not-close/do-not-close.tsx. Package requirements: lucide-react.

What props customize Do Not Close?

Do Not Close accepts `status`, `progress`, `label`, `doneLabel`, `error`. Configures do not close, beforeunload, payment processing behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of do-not-close?

Browsers decide whether to show the close warning and use their own text; mobile browsers often skip it. Can't prevent a crash, power loss or the OS killing the tab Server requirement: Make long operations resumable or idempotent on the server, so a closed tab or retry doesn't leave work half done or duplicated.

How does Do Not Close meet accessibility guidelines?

role="progressbar" with aria-valuenow and an aria-valuetext including time left. Status in a role="status" region; failures use role="alert". Retry is a labelled button. Minimizes errors: closed tab during payment, upload cancelled by closing tab.

Which components pair with Do Not Close?