A bar for trying a change before keeping it: the app shows a proposal live (a theme, a layout, an edit), and the bar says what it is and offers Keep, Throw away and Compare with the original. Compare is a toggle button (aria-pressed): a tap switches it on or off, and holding the button, or the Compare key (c), shows the original only while it is held. Screen readers use the toggle. A new proposal, a new label, is announced politely once and not again on later updates. An optional countdown (seconds) is drawn in view, hidden from screen readers, and throws the change away when it ends; it waits while the person compares. Escape in the bar throws the change away. When Keep or Throw away removes the bar while it has focus, focus moves on to the next control.
Install
Add PreviewBar from Ouro UI to this app. Read https:// ui.ouroboros.bot/ docs/ preview-bar.md first and follow it.Or by hand. Once per app, with Tailwind CSS v4 and an @/* path alias (Ouro HX is built on Base UI, so --base base; skip -t in an existing app):
npx shadcn@latest init --base base --preset nova --yes --no-monoreponpx shadcn@latest add ourostack/ouro-ui/ouro-base#v1.3.823Then the component (Installing):
npx shadcn@latest add ourostack/ouro-ui/preview-bar#v1.3.823Or, with the @ouro namespace set up:
npx shadcn@latest add @ouro/ouro-base @ouro/preview-barIts tests, stories and Playwright spec are optional. They need Vitest 4.1.11 or later, and from v0.8.0 never change a version your app has (Testing):
npx shadcn@latest add ourostack/ouro-ui/preview-bar#v1.3.823 ourostack/ouro-ui/preview-bar-tests#v1.3.823import { PreviewBar } from "@/components/ouro/preview-bar/preview-bar";Paths use shadcn's default @/ alias; the CLI rewrites them to yours.
Example
<PreviewBar label="Trying the Ocean theme" seconds={30} onKeep={keep} onDiscard={revert} onCompareChange={showOriginal} />Usage
The app owns the proposal: it renders the change, the original while onCompareChange says so, and removes the bar.
Use instead when
- Use
Alertinstead for a notice with no choice to make, andToastfor a message about something already done.
Props
Type: PreviewBarProps.
announcement- Type:
string - Default: the label, then "Reverts in N seconds unless you keep it" when there is a countdown
- What a screen reader hears for each new proposal.
className- Type:
string - Layout only: margins, width (
mt-6,max-w-md). Appearance classes warn in development. compareKey- Type:
string | false - Default:
"c" - The key that shows the original while it is held, from anywhere on the page except a text field.
falseturns the shortcut off. compareLabel- Type:
string - Default:
"Compare" - The label of the Compare button, a toggle.
discardLabel- Type:
string - Default:
"Throw away" - The label of the button that throws the change away.
keepLabel- Type:
string - Default:
"Keep" - The label of the button that keeps the change.
label(required)- Type:
string - What the app is showing, in words: "Trying the Ocean theme". It is the bar's name, and what a screen reader hears when a new proposal arrives. A new label is a new proposal.
onCompareChange(required)- Type:
(comparing: boolean) => void - Called with
truewhile the person is comparing, andfalsewhen they stop: show the original while it istrue, and the proposal again when it isfalse. onDiscard(required)- Type:
() => void - Called when the person throws the change away, presses Escape in the bar, or the countdown ends. The app puts the original back and removes the bar.
onKeep(required)- Type:
() => void - Called when the person keeps the change. The app makes it permanent and removes the bar.
seconds- Type:
number - Seconds before the change is thrown away, counted down in view and never read aloud. Counting stops while the person compares. Leave it out for a proposal that waits.
Don't use
These are not props. Passing one fails the type check with the fix in the error, and in development a console message names the fix.
onAccept: Not a prop. Ouro UI saysonKeep:<PreviewBar onKeep={() => …} />.timeout: Not a prop. The countdown isseconds:<PreviewBar seconds={30} />.
className is for layout only
Pass margins, width and grid placement (mt-4, w-full, col-span-2).
Appearance comes from props, not classes. In development, a class that sets appearance logs one warning per component instance, naming the prop to use instead. A class sets appearance when, after its variants (hover:, sm:) and any ! are removed, it starts with bg-, text-, border-, rounded-, shadow-, font-, ring-, from-, via-, to-, fill- or stroke-, or is border, rounded, shadow or ring, or has a dark: variant. Text wrapping, overflow and table layout classes (text-wrap, text-ellipsis, border-collapse) are layout and do not warn.
Alignment classes (text-center) warn too: set alignment on a parent element.

