Skip to content

SelectionToolbar

Stable

A small bar that appears over highlighted text, with quick edits, a menu of more, and a box to ask for your own.

Also known as floating toolbar, bubble menu, text selection menu

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

The standard bar

Nothing chosen yet.

Tab once to enter the bar. Arrow keys move between controls. Escape closes it.

When to use it

A small bar of quick AI edits for highlighted text, with a menu of more and a box to ask for your own edit. It does not position itself, so it fits into any editor.

Made of: Quick edit buttons · More options menu · Ask AI to edit box · Send button

Use it for

  • Rephrasing, shortening or changing the tone of highlighted text.
  • Asking for a custom edit to a selection in your own words.

Not for

Do and avoid

Do. A few quick edits, with the rest tucked into the menu.
Avoid. Eight quick edits in a row make each one hard to find.

Do

  • Offer every action in a right-click menu and with a keyboard shortcut too.
  • Show the result in a SuggestionBar, so nothing changes until it is chosen.
  • Return the cursor to the text when the bar closes.
  • Place the bar next to the highlighted text, because it does not position itself.

Avoid

  • Do not show it only when pointing.
  • Do not apply an edit straight from a button without a preview.
  • Do not add more than four or five quick edits. Put the rest in the menu.

On a phone

  • The bar wraps onto new rows. The Ask AI field is at least 192px wide and takes its own row when the chips fill the first.
  • The More menu opens as a bottom sheet with a backdrop on phones, and its items are at least 44px tall.
  • The ask field is 16px on touch screens, so the page does not zoom. The bar does no measuring, so place it clear of the system selection menu and the keyboard, and note that onClose only runs on Escape, which a phone does not have.

Seen in products

  • Google Docs with Gemini shows a floating Refine bar with Rephrase and Shorten and a More options menu (Elaborate, More formal, More casual, Bulletize, Summarize).
  • Notion lets you highlight text then choose Edit with AI, with a prompt such as fix grammar, make it shorter or change the tone.
  • Apple Intelligence Writing Tools offers Proofread, Rewrite (Friendly, Professional, Concise) and Summarize (paragraph, key points, table, list) system-wide.
  • Word Copilot has Draft with Copilot on selected text.

Build your next AI screen with Tattva.

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

Get started