Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Saved Draft Top Bar Banner Block for React

A top bar for a writing tool that reports its autosave with a green dot and a ticking time, and a Restore previous button that swaps in place to Restored with an Undo.

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

A top bar for React with Base UI, the status line of an editor. Anvilwell's strip sits between the page's rails on a faint tint: at the start a green dot, "Draft saved" in medium weight and how long ago, "12 seconds ago", which ticks every second and turns into minutes; at the end an underlined "Restore previous" button. Pressing it swaps, in the same place, to "Restored · Undo" and moves focus to Undo; pressing Undo swaps it back. Either press restarts the saved time and a polite status line says what happened. The two states share one grid cell, so nothing moves. It is not a notice, so it has no close; it is 44 pixels tall on a desktop and two lines at most on a phone. It follows your theme and is built from Guides and Status.

FAQ

How does the time tick without causing trouble?

The first save is a little old (12 seconds), and the age is worked out in the browser after the first render, so the server's markup is the same every time. Until then the line holds the room of "12 seconds ago" invisibly, so nothing shifts when it fills in. It is a time element with a machine-readable dateTime, updated once a second from Intl.RelativeTimeFormat: seconds first, then minutes. It is not inside a live region, so a screen reader is not told every second.

What do Restore previous and Undo do?

Nothing in the block saves a document: they flip a state and are the two places to call your own code. In restore bring back the previous version and, in undo, the latest one. Both reset the saved time to now (the document has just been saved again) and set the status line's text.

Where does focus go after Restore previous?

The button you pressed is replaced by the other state's, so focus is moved for you: to Undo after a restore, and back to Restore previous after an Undo. The hidden state is invisible and inert, so it can't be reached by Tab or read by a screen reader. Focus is moved in an effect after the change is on screen.

What does a screen reader hear?

The strip is a labelled "Draft status" region. A polite status line, empty until the first press, says "Previous version restored." or "Undone. Your latest draft is back." The ticking age is deliberately outside it.

Why is the dot green?

It stands for one real state: the draft is saved. It uses the success token and is hidden from assistive technology, because the words say the same. If saving can fail, switch the dot and the words together to the warning token and "Saving paused".

How does it fit on a phone?

At 393 pixels it is one line. At 320 pixels the status wraps to two ("Draft saved" and "12 seconds ago") beside the button, which keeps its own line. In right-to-left layouts the two ends swap and nothing scrolls sideways.

  • Pro

    A heartbeat callout for a monitoring tool: a framed status dot that sends out one ring on each poll, an all-systems-operational heading, a line with how long ago it checked and the p95 latency, and a status-page link.

  • Pro

    A sync callout for a data warehouse: one run plays on load, a counter rolling up to 1,248 records over a thin progress bar, then "Warehouse synced" with a countdown to the next run.

  • Pro

    A saved-settings toast pill for a settings panel: a success check, a message, an Undo button wearing a ring that drains over six seconds, and a dismiss button.

  • Pro

    A top bar for a team workspace manager that says which workspace you are in, with your role as a badge and a Switch menu of workspaces behind a divider.

  • Pro

    A slim announcement strip for a writing app's release: one centred line with the version, the news and an underlined link, and a ghost button that folds the strip away.

  • Pro

    An unsaved-changes pill for a form builder: a rolling count of changes, a small Save button and a ghost Discard, settling on a saved or discarded message.