React Native MantineOverlays

FloatingWindow

Draggable window moved by its header bar

Import: import { FloatingWindow } from 'react-native-mantine';

Usage

import {
  FloatingWindow,
  PortalProvider,
} from 'react-native-mantine';

// Wrap your app so the window can render in the overlay
<PortalProvider>
  <App />
</PortalProvider>

// Drag the header bar to move the window
<FloatingWindow
  title="Inspector"
  initialPosition={{ x: 12, y: 12 }}
  onPositionChange={({ x, y }) => console.log(x, y)}
  onClose={() => setOpened(false)}
  width={280}
>
  <Text size="sm">Window content</Text>
</FloatingWindow>

Props

PropTypeDefaultDescription
childrenReactNodeWindow content
titleReactNodeTitle displayed in the draggable header bar
initialPosition{ x: number; y: number }{ x: 20, y: 80 }Initial window position
onPositionChange(position: { x: number; y: number }) => voidCalled with the new position while the window is dragged
onDragStart() => voidCalled when dragging starts
onDragEnd(position: { x: number; y: number }) => voidCalled when dragging ends
onClose() => voidCalled when the close button is pressed, the button is not rendered without it
widthnumber280Window width in px
zIndexnumber400Window z-index
withinPortalbooleantrueDetermines whether the window should be rendered within Portal
portalTargetstringPortal host name used when withinPortal is set

Source on GitHub · npm