Overview
FloatingBlockActions is a self-managed component that displays floating action buttons when you hover over editor blocks. Perfect for adding quick actions like inserting new blocks, opening menus, or triggering AI features.

Features
- ✅ Auto-positioning - Automatically positions itself next to blocks
- ✅ Hover detection - Shows on hover, hides on mouse leave
- ✅ Frozen state - Can be “frozen” to keep it visible while other menus are open
- ✅ Compound components - Flexible button composition
- ✅ TypeScript - Full type safety
- ✅ Customizable - Complete styling control
Installation
Basic Usage
API Reference
Components
FloatingBlockActions.Root
Root container that handles positioning and visibility.
children: ReactNode- Button componentsclassName?: string- Custom CSS classesstyle?: CSSProperties- Inline styles
FloatingBlockActions.Button
Individual action button.
onClick?: (e: React.MouseEvent) => void- Click handlerdisabled?: boolean- Disable the buttontitle?: string- Tooltip textclassName?: string- Custom CSS classeschildren: ReactNode- Button content (usually an icon)- All standard button HTML attributes
Hooks
useFloatingBlockActions()
Full hook with all logic and state. Use this in your FloatingBlockActions component.
| Property | Type | Description |
|---|---|---|
floatingBlockId | string | null | ID of the block currently being hovered |
state | 'hovering' | 'frozen' | 'closed' | Current state of the component |
toggle | (state, blockId?) => void | Manually change state |
reference | HTMLElement | null | Internal reference element |
useFloatingBlockActionsActions()
Lightweight hook for controlling FloatingBlockActions from other components.
Examples
Basic Example with Multiple Buttons
With Drag and Drop
Conditional Buttons Based on Block Type
With Tooltips
Styling
CSS Variables
Customize the appearance using CSS variables:Custom CSS Classes
Inline Styles
States
The component has three states:1. Closed
Default state when not hovering any block.2. Hovering
Shows when hovering over a block. Automatically hides on mouse leave.3. Frozen
Stays visible even when mouse leaves. Useful when opening other menus (like BlockOptions) that need the floating actions to stay visible as a reference point.Best Practices
Always check if floatingBlockId exists
Always check if floatingBlockId exists
Use lightweight hook in other components
Use lightweight hook in other components
Freeze when opening menus
Freeze when opening menus
Keep buttons minimal
Keep buttons minimal
TypeScript
Accessibility
The component includes:- ✅ Keyboard navigation - Buttons are keyboard accessible
- ✅ Focus management - Proper focus states
- ✅ ARIA labels - Use
titleprop for tooltips - ✅ Button semantics - Proper
<button>elements withtype="button"