Interface AnchorPositionProps

Props of the useAnchorPosition hook.

interface AnchorPositionProps {
    getAnchorRect: (() => undefined | DOMRect);
    getContainerRect?: (() => undefined | DOMRect);
    getTargetRect: (() => undefined | DOMRect);
    isDisabled?: boolean;
    isRTL?: boolean;
    onPositionChange: ((info: Readonly<AnchorPositionInfo>) => void);
    variants?: AnchorPositionVariant[];
}

Properties

getAnchorRect: (() => undefined | DOMRect)

Returns a bounding rect of an anchor relative to a window around which a target is positioned.

getContainerRect?: (() => undefined | DOMRect)

Returns a bounding rect of a container that constrains a target positioning.

By default, window visual viewport is used as a container.

getTargetRect: (() => undefined | DOMRect)

Returns a bounding rect of an element that is positioned around an anchor.

isDisabled?: boolean

If true then anchored position of a target element isn't tracked.

false
isRTL?: boolean

If true then horizontal alignment is mirrored.

By default, RTL is derived a document.

onPositionChange: ((info: Readonly<AnchorPositionInfo>) => void)

A handler that is called when the target element must be repositioned.

Type declaration

    • (info): void
    • Parameters

      • info: Readonly<AnchorPositionInfo>

        An info about the current target position around an anchor. The info object is reused between handler invocations.

      Returns void

An array of target position variants from which the most suitable is picked.

By default, a single variant is used with default settings.