Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Sticky Bottom Pill Banner Block for React

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.

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

An unsaved-changes pill for React with Base UI, the bar that stays with a long form until the work is saved. A wide capsule sits in a muted shell between the page's rails: a rolling count, "3 unsaved changes", at the start, and a small outline Shine Button "Save" and a ghost "Discard" at the end. Pressing either rolls the count down to 0 and then the pill reads "All changes saved" or "Changes discarded", with an "Edit again" button that brings one change back so you can try it again. Focus follows to the button that appears and a polite line says what happened. Every wording and every set of buttons share one grid cell, so the pill never changes size. On phones it wraps to a rounded card with the buttons under the count. It follows your theme. It's built from Guides, Sliding Number, Shine Button and Button.

FAQ

How do I keep it at the foot of a long form?

Add sticky bottom-4 to the pill (the section named "Unsaved changes"). A sticky element stays inside its parent, so render the pill as the last child of the container that holds the whole form, not inside a short wrapper of its own: remove the block's wrapper padding and the page-width column, and place the pill after the form's fields. For a pill pinned to the viewport instead, use fixed inset-x-4 bottom-4 z-50 mx-auto. Keep room for the home indicator with bottom-[max(1rem,env(safe-area-inset-bottom))].

How do I connect the count to my form?

The count is the count state, and settle is where Save and Discard act. Derive the count from your form state (the number of dirty fields) and pass it in; call your save in save and your reset in discard, and let the pill settle when the promise resolves instead of after a fixed 700 ms. Show the pill only while the count is above 0 if you'd rather it came and went.

What does the count do under reduced motion?

The digits change in place instead of rolling, and the pill settles after the same short wait. Nothing else moves: the saved and discarded messages replace the count in the same cell without any shift.

What happens if someone presses Save twice?

While the count rolls, both buttons are aria-disabled and the handler ignores presses, so a second click does nothing and focus stays where it was. When the pill settles, focus moves to Edit again, and Edit again moves it back to Save, so a keyboard user is never left on a button that went away.

What do screen readers hear?

The pill's text is plain text, so it reads like any line. A polite status line, empty when the page loads, speaks "All changes saved" or "Changes discarded" when the pill settles and "1 unsaved change" after Edit again. Nothing is announced while the digits roll.

How does it fit on a phone?

Below sm the pill is a rounded card: the message on top and the two buttons under it, sharing the width. From sm it is one row, up to 36rem wide, with the count at the start and the buttons at the end. At 320 pixels nothing scrolls sideways, and in a right-to-left layout it mirrors.

  • 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 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.

  • Pro

    A release pill for a knowledge base: a New badge, one sentence about semantic search, a small Try it link and a dismiss button that folds the block away.

  • Pro

    An expiry callout for a certificate manager: a framed panel with a warning icon and a Shine Button that renews in place, turning the alert into a success, plus a ghost button that folds it away.

  • Pro

    A thumbs vote for a feature-flag tool that opens an optional comment box in place, with a Shine Button Send feedback, a ghost Skip and a thank-you line that replaces the vote.

  • Pro

    An install pill for a plant-care app: a greyscale app tile, the name, a row of stars with its score, a small Get link and a dismiss button that folds the block away.