Positioner
Utility component to help with positioning an element to an anchor.
Import#
import { Positioner, Placement } from '@volue/wave-react';// you may also access Positioner's context via hook:// import { usePositionerContext } from '@volue/wave-react';
Positioner is a compound component that consists of multiple parts:
-
Positioner.Root: The wrapper that contains all the parts of a positioner and provides context for its children. -
Positioner.Anchor: The reference component, thePositioner.Boxshould be anchored to. -
Positioner.Box: The box that positions its content dynamically relative toPositioner.Anchor. -
Positioner.Content: The content that pops out when the positioner is open.
Examples#
Basic#
Anchoring to any coordinates#
Positioner.Box can be anchored relative to something that isn't a DOM node, such as mouse position.
This is achieved by passing virtualRef property to Positioner.Anchor.
Read more about the concept of virtualRef at https://floating-ui.com/docs/virtual-elements.
In the example below, the box is located at the coordinates of a right-click.
API Reference#
Positioner.Root#
Prop | Type | Default |
|---|---|---|
children | React.ReactNode | No default value |
Positioner.Anchor#
Prop | Type | Default |
|---|---|---|
as | enum | div |
css | StitchesCss | No default value |
virtualRef | React.RefObject<Measurable> | No default value |
Positioner.Box#
Prop | Type | Default |
|---|---|---|
isOpen* | boolean | false |
placement | enum | "bottom_left" |
anchorOffset | number | 8 |
overflowPadding | number | 8 |
enableAutoUpdate | boolean | |
onExitComplete | function | () => void |
css | StitchesCss | No default value |
Positioner.Content#
Positioner.Content uses Motion Box under the hood.
Prop | Type | Default |
|---|---|---|
as | enum | div |
css | StitchesCss | No default value |