Introduction
Popper is a utility component for creating popovers, tooltips, and dropdowns. It’s a wrapper around Popper.js that provides positioning logic without any styling.Basic Usage
Props
open
- Type:
boolean - Required: Yes
true, the component is shown.
anchorEl
- Type:
HTMLElement | VirtualElement | (() => HTMLElement | VirtualElement) - Default:
null
children
- Type:
React.ReactNode | ((props: { placement: PopperPlacementType, TransitionProps?: object }) => React.ReactNode) - Default:
undefined
placement
- Type:
'auto' | 'auto-start' | 'auto-end' | 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end' - Default:
'bottom'
modifiers
- Type:
Array<Modifier> - Default:
undefined
popperOptions
- Type:
Partial<Options> - Default:
{}
popperRef
- Type:
React.Ref<Instance> - Default:
undefined
transition
- Type:
boolean - Default:
false
disablePortal
- Type:
boolean - Default:
false
children will be under the DOM hierarchy of the parent component.
keepMounted
- Type:
boolean - Default:
false
container
- Type:
HTMLElement | (() => HTMLElement) - Default:
document.body
Placement Examples
Transitions
Virtual Element
You can use a virtual element for positioning:Scroll Playground
Popper.js Modifiers
Offset Modifier
Prevent Overflow
Flip Modifier
Arrow Modifier
Popper Reference
Access the Popper.js instance:Fixed Positioning
Accessibility
Ensure proper ARIA attributes:Performance Tips
- Use
keepMountedfor frequently toggled poppers - Disable portal when not needed with
disablePortal - Memoize modifier configurations
- Use
popperRefto manually control updates
Common Use Cases
Dropdown Menu
Comparison with Popover
- Popper: Lightweight, no built-in styling, full Popper.js control
- Popover: Includes Paper styling, elevation, and backdrop support
- Custom styling
- Direct access to Popper.js features
- Lightweight positioning logic
- Material Design styling
- Backdrop and modal behavior
- Elevation and shadow effects