Overlay
Focus trap, scroll lock and dimming backdrop primitives for modals, sheets and palettes.
API reference
Components
<Backdrop />
Dimming scrim behind an open overlay.
opacity?
Scrim opacity as a number or bound MotionValue.
onClick?
Click-to-dismiss handler.
label?
When set, renders as a labelled dismiss button.
className?
Scrim surface class. Default bg-black.
style?
Extra inline styles.
children?
Content inside the scrim.
Hooks
useFocusTrap
Trap keyboard focus inside an open overlay.
useFocusTrap(options: FocusTrapOptions): voidactive
Whether the trap is engaged.
container
Ref to the overlay panel.
onEscape?
Called when Escape is pressed.
initialFocus?
Element focused when the trap engages.
restoreFocus?
Restore focus to the trigger on close. Default true.
useScrollLock
Freeze background scroll while active.
useScrollLock(active: boolean): voidFunctions
getFocusableElements
Tabbable descendants of container in document order.
getFocusableElements(container: HTMLElement | null): HTMLElement[]Featured in
See the overlay composed into full sections.
