Skip to content
GitHub (opens in a new tab)

SaveBar

A bar at the bottom of a form page that says what is unsaved and holds Discard and Save changes.

stableMoleculecontracts/savebar.json

Preview

SaveBar

A save bar that sticks to the bottom of main: what is unsaved, when it was last saved, then Discard and Save changes.

Master

Edit a field: it says Edited and the bar lists it. Clear the legal name and Save to see the error state.

Company

Printed on every invoice Northwind sends

Edited
Edited

Was USD · US dollar. Applies from INV-1843.

2 unsaved changes

Legal name, Invoice currency · last saved Nov 14 by Maya Chen

Usage

Put SaveBar last inside main, after the form, and set scroll-padding-bottom on the scroller to the bar height. Pass the changed field labels in changes and mark the same Fields with changed, old value in hint. Save is the page's one solid primary. On Save with field errors, set state error, say what to fix in message and focus an Alert summary (see Field). Leaving with changes opens AlertDialog in the app; closing the tab can only use the browser's own prompt.

Do's

  • a settings or details form where edits stay unsaved until Save
  • say which fields changed and when the page was last saved
  • keep Save in reach on a long form, including on a phone

Don'ts

  • a short form that ends in its own Buttons, like a Card or Modal footer — use Card actions or ModalCard
  • a setting that saves as soon as it changes (a Switch) — show a Toast instead
  • a page-level message about the whole workspace — use Alert
<main style={{ scrollPaddingBottom: "4rem" }}>
  <form>…</form>
  <SaveBar
    state="dirty"
    changes={["Legal name", "Invoice currency"]}
    savedAt="Nov 14 by Maya Chen"
    onDiscard={discard}
    onSave={save}
  />
</main>

A save bar that sticks to the bottom of main on a form page. It says what is unsaved ("2 unsaved changes" and the field names), when it was last saved, or what stopped the save, and holds Discard and Save changes. Save is the page's one solid primary.

When to use

  • a settings or details form where edits stay unsaved until Save
  • say which fields changed and when the page was last saved
  • keep Save in reach on a long form, including on a phone

When not to use

  • a short form that ends in its own Buttons, like a Card or Modal footer — use Card actions or ModalCard
  • a setting that saves as soon as it changes (a Switch) — show a Toast instead
  • a page-level message about the whole workspace — use Alert

What an agent reads

import { SaveBar } from "agentic-ds-kit";
must
  • role=region named by saveLabel ("Save changes"); an aria-label you pass wins
  • The status line is role=status, aria-live polite: "2 unsaved changes", "Saved at 10:42", "Not saved · 1 field to fix"
  • Put it after the form in the DOM so it comes after the fields in tab order
  • Sticky to the bottom of its scroll container; the page sets scroll-padding-bottom to the bar height so a focused field is never hidden under it
  • Wide: one 64px row, md 36 Buttons. Under 30rem of bar width: the status on top, then Discard (one third) and Save (two thirds) at lg 40
  • Leaving with changes: the app opens AlertDialog for in-app navigation. Closing the tab can only use the browser's own beforeunload prompt
defaults
  • state dirty
  • saveLabel Save changes
  • discardLabel Discard
  • saving false
stops if
  • Do not add a second solid primary Button to the page: Save is the one
  • Do not invent a local FormFooter, StickyActions or UnsavedBanner
  • Do not show the unsaved state by colour alone: the status line says it in words
  • Do not put role=alert on the status line; the error summary Alert takes focus on Save
  • Do not use raw hex

From contracts/savebar.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
statesaved | dirty | errorNodirtysaved: CircleCheck (icon.success), Discard hidden, Save disabled. dirty: CircleAlert (icon.warning). error: CircleX (icon.danger), status in status.dangerText, top edge status.dangerBorder. The icon is aria-hidden; the words carry the state.
changesarrayNo—string[] of changed field labels, e.g. ["Legal name", "Invoice currency"]. The count makes the dirty status ("2 unsaved changes"); the names make the muted line under it. Mark the same fields with Field changed.
savedAtstringNo—Pre-formatted, e.g. "10:42" or "Nov 14 by Maya Chen". Saved reads "Saved at 10:42"; dirty and error add "last saved Nov 14 by Maya Chen" to the muted line.
messagestringNo—The status line in your words; replaces the default ("2 unsaved changes", "Saved at 10:42", "Not saved"). In the error state say what to fix: "Not saved · 1 field to fix". Also the way to translate.
onDiscardfunctionNo—Renders an outline neutral Discard Button. Hidden in the saved state. Ask with AlertDialog first when discarding loses a lot.
onSavefunctionYes—The solid primary Save Button, disabled in the saved state. On Save with field errors, focus an Alert summary (see Field) and set state error.
saveLabelstringNoSave changesAlso names the region.
discardLabelstringNoDiscardCancel when leaving the page is the outcome.
savingbooleanNofalseSave shows its spinner (Button loading) and Discard is disabled while the request runs.
  • Component
    →

    Card

    Framed tile with optional header, body, and footer actions.

  • Component
    →

    Modal

    Dismissible overlay for short tasks, forms, or extra detail.

  • Component
    →

    ModalCard

    The panel chrome for a modal: one shared header (tone icon + eyebrow, Close, h2 title, description) and footer (footerStart left, actions right).

  • Component
    →

    Switch

    Immediate on/off setting.