useXDSLayer@xds/core · Layer

Usage

Layer is a core positioning hook for rendering overlay content using CSS Anchor Positioning and the Popover API. Use it as the foundation for building popovers, hover cards, and tooltips without React portals.

Best practices

GuidancePractices
DoUse context mode for anchor-positioned overlays relative to a trigger element, and fixed mode for manually positioned overlays at specific coordinates.
DoBuild on higher-level components like Popover, HoverCard, and Tooltip instead of using Layer directly for common overlay patterns.
Don'tImplement ARIA patterns directly in a Layer — leave accessibility semantics to the higher-level components that build on it.

Import

ts
import {useXDSLayer} from '@xds/core/Layer'

Props

PropTypeDescription
moderequired
'context' | 'fixed'Positioning strategy: context uses CSS anchor positioning relative to a trigger ref; fixed uses explicit x/y coordinates.
onShow
() => voidCallback fired when the layer becomes visible.
onHide
() => voidCallback fired when the layer is hidden.
xstyle
StyleXStylesStyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value — not an inline style object like style={{}}.