Skip to content

Components

SaveBar

Component reference

Properties

Use SaveBar

A persistent save and discard panel for forms with an unsaved draft.

Example import style
save-bar.tsxTSX
"use client";

import { FloodRoot, SaveBar } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <SaveBar form="project-settings" state="dirty" />
    </FloodRoot>
  );
}

Design notes

  • Use the default viewport placement when the end of a long form may be out of view. Place the bar near the view root, outside transformed or clipped containers. Reserve enough bottom clearance in the scroll owner for the last field. Use inline placement within an overlay or a constrained panel.
  • Pass the target form ID when rendering outside that form. Save and Discard use native submit and reset, so the form owns validation, persistence, controlled field reset and navigation guards.
  • Drive state from the real draft and request. Change to clean after successful save or reset. Keep the draft on error, supply a useful state label and allow retry. If saving or resetting hides the focused bar, return focus to a persistent form control.

API reference

PropValuesDefault
state"clean" | "dirty" | "saving" | "error"Required
formstring—
placement"viewport" | "inline""viewport"
saveDisabledbooleanfalse
announceboolean—
labels{ group?: string; save?: string; discard?: string; state?: Partial<Record<Exclude<SaveBarState, "clean">, string>>; }—
Native HTML propsOmit<HTMLAttributes<HTMLDivElement>, "children" | "role">Forwarded
View TypeScript source