Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Loading Dialog Block for React

A release tool's page with its publish alert shown open: a four-step run that starts when you press the button, never moves the dialog while it waits, shows skeleton boxes where the file sizes will be, and can be stopped.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Show a wait without making the page jump, with this publish alert for React with Base UI. It opens from the Release page of Shipmoor, a release tool: the header holds an outline Review release Button, and the page itself, four joined boxes and the release's notes with a Draft chip, is drawn under a soft scrim inside a hairline frame with a plus mark on each corner. The Alert Dialog lists four steps, packing, uploading, verifying and publishing, each with a glyph and a word, Waiting, Running, Done or Stopped, over a Progress bar that fills one step at a time and says "2 of 4 done". Under them, three files list their sizes: until the run has packed them each size is a Skeleton box in the exact cell the number will take, and the region is marked busy. Escape does nothing while it runs, there is no outside click on an alert, and Stop halts it with "Stopped at step 2. Nothing was published". The only Shine Button starts it, and Start over runs it again. Finishing turns the drawn chip from Draft to Live. For preview the alert is drawn open in place when the page loads, and nothing runs until you press Publish release; the header button opens the real Alert Dialog, with the same run.

FAQ

Why is the alert already open, and what do I keep?

So you can see it without a click. On load the alert is a copy drawn in place over the page: a native dialog element with the alertdialog role that isn't modal, so nothing is trapped, hidden or focused, and the page around the preview keeps working. The Review release button opens the real Alert Dialog, modal, with its focus trap and Escape, and the copy stays closed until a reload. Both show the same RunFields component and share the block's state, so a run started in the copy carries on in the real one. In your app keep the Alert Dialog and drop the copy: the "in-place" state, the scrim and the dialog element inside the frame.

How does the dialog stay still while it loads?

Every part has its place before it has its content. The four steps are rows of one height; the word at the end of each row has a fixed width; the sizes sit in cells as tall as the numbers, and a skeleton fills the same cell, so nothing is inserted, removed or resized when a state changes. The bar's track is always there, the description under the title keeps its two lines, and the region that loads is marked aria-busy while it does, with "Loading file sizes" for screen readers. The numbers swap in place when the run is done.

How long does it wait, and what starts it?

It starts when Publish release is pressed and takes about four and a half seconds: 0.9, 1.5, 1.2 and 0.8 seconds for the four steps, one timer each, so the wait is bounded and nothing runs on load or in the copy until then. The bar is a CSS transition for the length of the step, so it can't drift from the clock; with reduced motion the bar jumps from step to step and the spinner stops turning, since the steps still carry the information. A polite message names each step as it starts.

What do Stop and Escape do while it runs?

Stop halts the run at once: the step it was on reads Stopped, the bar drops back to the steps that finished, the sizes stay as dashes, and the description says nothing was published. Start over runs the four steps again. Escape and the outside click do nothing while it runs, because the alert refuses to close until the run ends or is stopped; Cancel is Stop in that time. After it ends or is stopped, Cancel and Escape close it and return focus to Review release.

Where does focus go?

The real alert opens with focus on Cancel. Pressing Publish release moves focus to Stop, so the one thing that matters while it runs is under the keyboard; when the run ends, focus goes to Done, and after a stop to Start over. Cancel is the focus target through initialFocus.

What stays local in the demo, and how do I wire it up?

All of it. Nothing is packed, uploaded or published: the steps are timers, the files and sizes are typed, and finishing only turns the drawn chip to Live. In your app start the real job in start, move step from your server's progress events instead of timers, keep the dialog from closing with the same check in openTo, and fill the sizes from the response; cancel the job on the server when someone presses Stop.

  • Pro

    API Error Dialog

    Status and errors

    A deploy platform's overview with its failed card and the error alert shown open: the 502 status, the code and request id, a retry ladder of three attempts, a real copy of the error report and the error body as a JSON tree.

  • Pro

    Session Timeout Dialog

    Status and errors

    A bank's accounts page with an alert dialog shown open that warns before an idle session ends: a one-minute clock with a draining bar, Stay signed in and Sign out now, and a signed-out view at zero.

  • Pro

    A usage-report tool's Exports page with its export dialog shown open: a CSV or JSON format, a range with row counts, six fields behind a mixed Select all box and a size estimate, and a Download button that saves a real file.

  • Pro

    A CRM's empty Contacts page with a full-screen import dialog shown open: upload a CSV or use a sample, match six columns to fields with Selects, review new, duplicate and error counts with row numbers, and import with a filling bar.

  • Pro

    A media library with twelve files ticked and the dialog that acts on all of them: a scrolling list of the files, four action cards, the chosen action's own control, a bar that fills, and a destructive button for delete.

  • Pro

    Success Dialog

    Status and errors

    An invoice page with its payment confirmation shown open: a dialog with a drawn check, a receipt list with a copy button for the reference, and one button that settles the invoice.