Skip to content

Floating Toolbar

Last updated 27 Oct 2026

NbFloatingToolbar is a small bar of controls that floats next to something on the page: formatting buttons over a text selection, actions over a selected image, alignment controls over a table cell. It holds ordinary NbButtons, places itself with the same flip-and-clamp logic as NbInfoHint, and is careful never to take focus from the thing it acts on.

Select some text in the paragraph below.

Placement ​

placement is a preference. A toolbar over a selection on the first line of a page has no room above it, so it flips below, then to the sides, and finally clamps itself inside the viewport. When the anchor scrolls entirely out of view the toolbar hides rather than sitting clamped against the edge of the window, acting on text nobody can see.

Focus ​

Three rules, all of which exist because the toolbar's main consumer is a text editor:

  • Appearing never moves focus. The editor keeps the caret and the selection.
  • Pressing a button never moves focus. The toolbar cancels mousedown, which is the event that would focus the button and blur the editor. The click still fires. Text fields inside the toolbar (a link URL, say) are exempt, since they genuinely need focus.
  • Keyboard users get in deliberately. Call the exposed focus() from your editor's shortcut (Alt+F10 is the common one), and return focus to the editor yourself on close.