Skip to content

RevertToggle

Stable

Lets people flip between the AI's suggestion and their own edit, with a way back to the original.

Also known as undo, restore previous, before after toggle

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

After an edit

Thanks for your patience. The fix ships Friday.

Reverting drops the edit here, and the switch goes away.

When to use it

Shows one version of a short text at a time, so people can flip between the AI suggestion and their own edit. The original is kept so they can always go back.

Made of: Version switch · Revert button · Text · Status for screen readers

Use it for

  • A short AI suggestion the person has edited, such as a reply draft or a title.
  • Comparing the AI's wording with the person's own before they keep one.
  • Dropping an edit and going back to the original suggestion.

Not for

  • Long text where people need to see exactly what changed: use DiffView.
  • Several versions of one chat message: use VersionPager.

Do and avoid

Lisbon weekend with Sam
Do. A short title flips between the AI version and the edit.
Day one: walk the old town, lunch near the castle, then a tram to the river. Day two: a boat trip and dinner by the harbour.
Avoid. Long text swaps as a whole, so nobody can spot what changed.

Do

  • Keep the AI version until the person reverts or discards it.
  • Use it for short text where a side-by-side view would be too much.
  • Clear the edit in onRevert. The part shows the AI version but does not remove your stored edit.

Avoid

  • Do not overwrite the AI version when the person edits.
  • Do not use it for long documents. A view that highlights changes fits better.
  • Do not show the switch before an edit exists.

On a phone

  • The switch and the Revert button sit on one line and wrap when they do not fit.
  • The two switch options keep their size and have a 44px tap area on a touch screen, and their labels do not wrap.
  • The value card fills the width, so long text wraps inside it.

Seen in products

  • IBM Carbon for AI defines a Revert pattern. People toggle between AI-suggested and user-edited content and can return to the original AI value.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started