Overview
TheSelectionBox component enables rectangle selection (also known as “marquee selection” or “lasso selection”) for selecting multiple blocks at once. When the user clicks and drags outside the editor area, a selection rectangle appears, and all blocks that intersect with this rectangle become selected.

Features
- ✅ Rectangle selection for multiple blocks
- ✅ Works outside the editor area
- ✅ Automatic block selection based on intersection
- ✅ Supports custom container element
- ✅ Respects read-only mode
- ✅ Lightweight and performant
Basic Usage
API Reference
SelectionBox Component
The main component that renders the selection rectangle and handles mouse events.
Props
useRectangeSelectionBox Hook
For advanced use cases, you can use the hook directly to build custom selection UI.
Hook Parameters
Hook Return Value
Types
Examples
Basic Setup with Container Ref
Full Page Selection
For full-page selection support, pass a ref to the outermost container:Without SelectionBox
If you don’t need rectangle selection, simply don’t include the component:How It Works
- Mouse Down - When the user clicks outside the editor (but inside the container), the selection starts
- Mouse Move - As the user drags, the selection rectangle grows/shrinks
- Block Detection - Blocks that intersect with the selection rectangle are marked as selected
- Mouse Up - Selection ends, selected blocks remain highlighted
- Click Outside - Clicking outside clears the selection
- Copied (
Ctrl/Cmd + C) - Cut (
Ctrl/Cmd + X) - Deleted (
BackspaceorDelete)
Styling
The default selection box has a semi-transparent blue background:useRectangeSelectionBox hook and build your own UI.
Best Practices
Use a wrapper container
Use a wrapper container
Always wrap your editor in a container element and pass that ref to SelectionBox.
This ensures selection works in the area outside the editor content.
Don't pass editor element as container
Don't pass editor element as container
The container should NOT be a child of the editor. The SelectionBox needs to capture
mouse events outside the editor content area.
Pass ref object, not ref.current
Pass ref object, not ref.current
Pass the ref object itself, not
ref.current. This ensures the component can access
the element even if it’s not mounted on the first render.Accessibility
- Selection box is purely visual and doesn’t affect screen readers
- Selected blocks are still accessible via keyboard navigation
- Use keyboard shortcuts (
Ctrl/Cmd + A) for full selection as an alternative
Related Components
FloatingBlockActions
Actions that appear when hovering over blocks
BlockOptions
Context menu for block operations

