### Window with Position and Size Callbacks Source: https://gfazioli.github.io/mantine-window/index This example shows how to use `onPositionChange` and `onSizeChange` callbacks to react to window movements and resizing. The callbacks log the new position or size to the console. ```typescript import { Window } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( { // eslint-disable-next-line no-console console.log('Position changed:', pos); }} onSizeChange={(size) => { // eslint-disable-next-line no-console console.log('Size changed:', size); }} > Open console to see callbacks

Move or resize this window to trigger callbacks

); } ``` -------------------------------- ### Install Mantine Window with NPM Source: https://gfazioli.github.io/mantine-window/index Installs the @gfazioli/mantine-window package using the NPM package manager. This command is equivalent to the Yarn installation for NPM users. ```bash npm install @gfazioli/mantine-window ``` -------------------------------- ### Install Mantine Window with Yarn Source: https://gfazioli.github.io/mantine-window/index Installs the @gfazioli/mantine-window package using the Yarn package manager. This is the first step to integrating the component into your project. ```bash yarn add @gfazioli/mantine-window ``` -------------------------------- ### Multiple Windows Management Source: https://gfazioli.github.io/mantine-window/index This example demonstrates how to render and manage multiple windows within the same container. Each window has a unique `id` for state persistence and can be brought to the front by clicking on it. ```typescript import { Window } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( First Window

Click on a window to bring it to front

Second Window

Click on a window to bring it to front

); } ``` -------------------------------- ### Create Responsive Window with Viewport Units Source: https://gfazioli.github.io/mantine-window/index Illustrates how to create a responsive Mantine Window by combining viewport units (vw, vh) for position and size. This example also includes pixel-based minimum and viewport-based maximum size constraints. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Button, Stack, Text, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [opened, { open, close }] = useDisclosure(false); return ( <> Viewport-based Position & Size Position: x: 5vw, y: 10vh Size: width: 50vw, height: 40vh Min: 300px x 200px Max: 90vw x 80vh This window combines viewport units for position and size with pixel-based minimum constraints and viewport-based maximum constraints. All units are relative to the viewport. ); } ``` -------------------------------- ### Enable Full Size Resize Handles in Mantine Window Source: https://gfazioli.github.io/mantine-window/index This example shows how to enable full-size resize handles for the Mantine Window component by setting the `fullSizeResizeHandles` prop to `true`. This feature extends the resize handles to span the entire edge of the window, offering a larger and more user-friendly interaction area for resizing. Corner handles remain for diagonal resizing. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( Full Size Resize Handles

With fullSizeResizeHandles enabled, the side handles (top, bottom, left, right) span the entire width or height of the window.

This makes it easier to resize from any edge, while corner handles (14x14px) remain for diagonal resizing.

); } ``` -------------------------------- ### Window with Persistent State Source: https://gfazioli.github.io/mantine-window/index This example demonstrates how to persist the window's position, size, and collapsed state using the `persistState` prop. The window's state is saved in localStorage and restored upon page refresh. ```typescript import { Window } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( Position, size, and collapsed state are saved in localStorage

Move, resize, or collapse/expand this window, then refresh the page

The window will remember its last position, size, and collapsed state

); } ``` -------------------------------- ### Set Initial Window Position with defaultPosition Prop Source: https://gfazioli.github.io/mantine-window/index Allows setting the initial position of the window using the `defaultPosition` prop. This prop accepts an object with `x` and `y` coordinates to specify where the window should appear on the screen when it's first opened. This is particularly useful for embedded UI components or when a specific starting location is desired. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( This window starts at x:200, y:150 ); } ``` -------------------------------- ### Centered and Fixed Window Source: https://gfazioli.github.io/mantine-window/index This example creates a window that is centered and cannot be moved or resized. It uses `resizable="none"` and `draggable="none"` props to disable these interactions. ```typescript import { Window } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( Centered, fixed window

This window is centered and cannot be moved or resized

); } ``` -------------------------------- ### Disable Window Collapsing Source: https://gfazioli.github.io/mantine-window/index This example shows how to disable the collapsing functionality of the window by setting the `collapsable` prop to `false`. This removes the collapse button and the double-click header behavior. ```typescript import { Window } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( This window cannot be collapsed ); } ``` -------------------------------- ### Basic Mantine Window Usage (React) Source: https://gfazioli.github.io/mantine-window/index Demonstrates the basic usage of the Mantine Window component in a React application. It shows how to set default position, size, and enable features like `withinPortal: false` for relative positioning. ```jsx import { Window, type WindowProps } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( {/** In this demo, the Window is positioned relative to its parent container. Check the docs below to learn more about the "withinPortal" prop. */} This is a window with data ); } ``` -------------------------------- ### Set Custom Initial Window Size with defaultSize Prop Source: https://gfazioli.github.io/mantine-window/index Enables setting custom initial dimensions for the window using the `defaultSize` prop. This prop takes an object with `width` and `height` properties to define the window's size upon its first appearance. This provides control over the initial visual footprint of the window. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( This window is 500x400 pixels ); } ``` -------------------------------- ### Viewport-based Constraints for Mantine Window Source: https://gfazioli.github.io/mantine-window/index Demonstrates how to use viewport units (vw, vh) to set responsive minimum and maximum size constraints for the Mantine Window component. These constraints adapt to the browser window size, ensuring the window scales proportionally. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Button, Stack, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [opened, { open, close }] = useDisclosure(false); return ( <> Viewport-based Min/Max Size

Min: 30vw x 20vh

Max: 80vw x 70vh

Try resizing your browser window to see the constraints adapt!

); } ``` -------------------------------- ### Mixed Unit Constraints for Mantine Window Source: https://gfazioli.github.io/mantine-window/index Illustrates how to combine different unit types (pixels and viewport units) for setting minimum and maximum size constraints on the Mantine Window component. This allows for flexible hybrid sizing strategies. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Button, Stack, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [opened, { open, close }] = useDisclosure(false); return ( <> Mixed Units

Min Width: 300px (fixed)

Min Height: 15vh (viewport-based)

Max Width: 60vw (viewport-based)

Max Height: 600px (fixed)

); } ``` -------------------------------- ### Size Window with Percentage Units Source: https://gfazioli.github.io/mantine-window/index Demonstrates how to set the size of a Mantine Window using percentage units. When `withinPortal` is false, percentages are relative to the parent container. Ensure the parent container has a defined size and position. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Box, Stack, Text, Title } from '@mantine/core'; function Demo() { return ( Size with Percentage Size: width: 60%, height: 50% Reference: Parent container (dashed border) The window size is 60% of container width and 50% of container height. Percentage units with withinPortal=false are relative to the parent container. ); } ``` -------------------------------- ### Import Mantine Window Styles Source: https://gfazioli.github.io/mantine-window/index Imports the default styles for the Mantine Window component at the root of your application. This ensures the component is styled correctly. ```javascript import '@gfazioli/mantine-window/styles.css'; ``` -------------------------------- ### Control Window Positioning with withinPortal Prop Source: https://gfazioli.github.io/mantine-window/index Demonstrates how to use the `withinPortal` prop to control window positioning. `withinPortal={true}` (default) uses fixed positioning relative to the viewport, while `withinPortal={false}` uses absolute positioning relative to its parent container. The parent container must have `position: relative` for absolute positioning to work correctly. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Button, Group, Stack, Text, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [portalOpened, { open: openPortal, close: closePortal }] = useDisclosure(false); const [containerOpened, { open: openContainer, close: closeContainer }] = useDisclosure(false); return ( <> {/* Window with withinPortal={true} (default) - fixed positioning */} Portal Window This window uses withinPortal=true (default). It is positioned fixed relative to the viewport and will stay in place even when scrolling. {/* Container for relative window */} Container with position: relative {/* Window with withinPortal={false} - absolute positioning */} Container Window This window uses withinPortal=false. It is positioned absolute relative to its parent container and cannot be dragged or resized outside the container boundaries. ); } ``` -------------------------------- ### Constrain Window Resize with Min/Max Dimensions Source: https://gfazioli.github.io/mantine-window/index Shows how to enforce minimum and maximum dimensions for a Mantine Window during resize operations using `minWidth`, `minHeight`, `maxWidth`, and `maxHeight` props. This ensures the window stays within defined boundaries. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( Try resizing this window

Min: 300x200px

Max: 600x450px

); } ``` -------------------------------- ### Styling Mantine Window Component using Styles API Source: https://gfazioli.github.io/mantine-window/index This snippet illustrates how to apply custom styles to the Mantine Window component using its Styles API. The `classNames` prop allows targeting specific inner elements of the window, such as the root, container, content, header, and resize handles. This enables detailed visual customization of the component. ```css /* * Hover over selectors to apply outline styles * */ ``` -------------------------------- ### Create a Non-Collapsible Window with Mantine Window Source: https://gfazioli.github.io/mantine-window/index This code snippet demonstrates how to create a window component using '@gfazioli/mantine-window' that cannot be collapsed by double-clicking its header. It utilizes the `collapsable={false}` prop to disable this functionality. The component is configured with basic properties like `title`, `opened`, `defaultPosition`, `defaultSize`, `persistState`, and `withinPortal`. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( This window cannot be collapsed

Double-clicking the header will not collapse the window

); } ``` -------------------------------- ### Position Window with Percentage Units - React Source: https://gfazioli.github.io/mantine-window/index Illustrates positioning the Mantine Window component using percentage units. When `withinPortal={false}`, percentages are relative to the parent container, which must have `position: relative`. This allows for positioning relative to a specific DOM element. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Box, Stack, Text, Title } from '@mantine/core'; function Demo() { return ( Position with Percentage Position: x: 10%, y: 15% Reference: Parent container (dashed border) With withinPortal=false, percentage units are calculated relative to the parent container, not the viewport. The parent must have position: relative. ); } ``` -------------------------------- ### Controlled Mantine Window (React) Source: https://gfazioli.github.io/mantine-window/index Illustrates how to control the open and close state of the Mantine Window component using React hooks (`useDisclosure`). This allows programmatic management of the window's visibility. ```jsx import { Window } from '@gfazioli/mantine-window'; import { Button, Stack, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [opened, { open, close }] = useDisclosure(false); return ( This is a window ); } ``` -------------------------------- ### Position Window with Viewport Units (vw/vh) - React Source: https://gfazioli.github.io/mantine-window/index Demonstrates positioning the Mantine Window component using viewport units (vw/vh). These units are always relative to the browser viewport, ensuring the window's position adapts to the browser window size. Use `withinPortal={true}` (default) for consistent behavior. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Button, Stack, Text, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [opened, { open, close }] = useDisclosure(false); return ( <> Position with Viewport Units Position: x: 10vw, y: 15vh Reference: Viewport (browser window) Viewport units (vw/vh) are always relative to the browser viewport. The position adapts proportionally when resizing the browser window. ); } ``` -------------------------------- ### Percentage Drag Boundaries for Mantine Window Source: https://gfazioli.github.io/mantine-window/index Set drag boundaries for Mantine Window using percentage values relative to the viewport or container. This provides a flexible way to constrain window movement proportionally. The `dragBounds` prop accepts percentage strings for `minX`, `maxX`, `minY`, and `maxY`. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Box, Stack, Title } from '@mantine/core'; function Demo() { return ( Percentage Boundaries

X Bounds: 5% to 75%

Y Bounds: 5% to 75%

Boundaries are percentage of viewport/container size.

); } ``` -------------------------------- ### Import Mantine Window Layer Styles Source: https://gfazioli.github.io/mantine-window/index Imports the Mantine Window component styles within a specific layer named 'mantine-window'. This can be useful for managing CSS specificity and order. ```javascript import '@gfazioli/mantine-window/styles.layer.css'; ``` -------------------------------- ### Viewport-based Drag Boundaries for Mantine Window Source: https://gfazioli.github.io/mantine-window/index Configure Mantine Window to use viewport units (vw, vh) for responsive drag boundaries. This ensures windows stay within proportional limits relative to the browser window size. The `dragBounds` prop accepts viewport units for `minX`, `maxX`, `minY`, and `maxY`. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Button, Stack, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [opened, { open, close }] = useDisclosure(false); return ( <> Viewport-based Boundaries

X Bounds: 10vw to 70vw

Y Bounds: 10vh to 70vh

Try dragging this window - it stays within viewport-based boundaries!

Resize your browser to see bounds adapt.

); } ``` -------------------------------- ### Drag Boundaries for Mantine Window Source: https://gfazioli.github.io/mantine-window/index Shows how to restrict the draggable area of the Mantine Window component using the `dragBounds` prop. This ensures the window remains within a defined rectangular region on the screen. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Box, Title } from '@mantine/core'; function Demo() { return ( Try dragging this window

It can only move within specific bounds:

X: 50-500, Y: 50-400

); } ``` -------------------------------- ### Size Window with Viewport Units (vw/vh) - React Source: https://gfazioli.github.io/mantine-window/index Shows how to set the size of the Mantine Window component using viewport units (vw/vh). These units ensure the window's dimensions scale proportionally with the browser viewport. Use `withinPortal={true}` (default) for consistent behavior. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Button, Stack, Text, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [opened, { open, close }] = useDisclosure(false); return ( <> Size with Viewport Units Size: width: 40vw, height: 50vh Position: x: 5vw, y: 10vh The window size and position scale proportionally with the viewport. Try resizing your browser window to see the window adapt! ); } ``` -------------------------------- ### Mixed Unit Drag Boundaries for Mantine Window Source: https://gfazioli.github.io/mantine-window/index Combine different unit types (pixels, viewport units, percentages) for drag boundaries in Mantine Window. This allows for sophisticated constraints by mixing fixed pixel values with responsive viewport units or percentages. The `dragBounds` prop supports a mix of number (pixels) and string (vw, vh, %) values. ```tsx import { Window } from '@gfazioli/mantine-window'; import { Button, Stack, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [opened, { open, close }] = useDisclosure(false); return ( <> Mixed Unit Boundaries

Min X: 50px (fixed)

Max X: 80vw (viewport-based)

Min Y: 10vh (viewport-based)

Max Y: 450px (fixed)

Mix different unit types for flexible boundaries!

); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.