Skip to contentKino
Skip to Content

Save bar

A bar that rises from the bottom of the screen while a form has unsaved changes, with Discard and Save. It shows the save running, leaves once it has worked, and swells to say no when the person tries to leave first.

npx shadcn add https://kinoui.com/r/save-bar.json
Share on

Examples

kinoui.com/

Your team finds the workspace here.

Default

Put it in a Form, after the fields, and save in onFormSubmit: change a field and the bar rises; a promise shows the save running, and the bar leaves once it has worked.

Invoices and receipts go here.

Failing save

A rejection or a throw from onFormSubmit keeps the changes and says the save failed, so the person can try again.

A summary of the cycle every Monday at 9:00.

Controlled

Discard puts every Field back to its defaultValue; put state you own back in onDiscard.

Installation

npx shadcn@latest add https://kinoui.com/r/save-bar.json
Files
lib/refs.tslib/reduce-motion.tslib/resize.tslib/swap.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxcomponents/kino/label.tsxlib/settle.tscomponents/kino/field.tsxlib/announce.tsxlib/keys.tsxlib/refuse.tslib/scroll.tslib/form-changes.tsxcomponents/kino/save-bar.tsx
Packages
@base-ui/reactclass-variance-authority

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

SaveBar

PropTypeDefaultDescription
onDiscard() => voidNoneRuns after Discard has put every Field back to its defaultValue, for state the form doesn’t hold, such as a controlled field’s. Keep each defaultValue on what was last saved, so Discard puts back only what changed since.
containerHTMLElementnullNoneAn element of your own to render into, in place of the end of the page.
classNamestringNoneFor layout. The bar lines up with its form across the screen.

SaveBarContainer

PropTypeDefaultDescription
containerHTMLElementnullNoneWhere the bars inside it render.

Data attributes

AttributeOnDescription
data-openSaveBarPresent while the form has changes, or is saving them.
data-viewSaveBarchanged, saving, saved as it leaves, failed, or blocked after a try to leave.
data-refusedSaveBarPresent while it swells to say no to leaving.

CSS variables

VariableSet it onDefaultDescription
--save-bar-insetSaveBar, or <html>1remHow far above the bottom of the screen the bar sits.

Accessibility

  • The bar is a region named “Unsaved changes”, read after the form’s last field though it renders at the end of the page. It never takes focus as it appears, so typing carries on; Tab reaches it after the form’s last field, and Tab from Save goes on to what follows the form.
  • A polite status region, there from the start, says when the bar shows, when a save starts, when it has worked, when it fails and when changes are discarded.
  • ⌘S or Ctrl+S saves while there are changes; Save carries the shortcut in aria-keyshortcuts. Escape does nothing, so changes are never thrown away by a key.
  • With changes unsaved, a link away or Back is stopped and the bar says to save or discard first, in words and in the warning colour, not by its swell alone; closing or reloading the tab asks the browser’s own question.
  • A focused field the bar would cover is scrolled clear of it. When the bar leaves with focus in it, focus goes back to the control last used.
  • Under reduced motion the bar fades in and out where it rests, and doesn’t swell; every state still shows in words.