TwitterGitHub
Dark LogoStratik / UIbeta
useResizable

This hook is used to handle the resizing of an element. It can be used in multiple ways, such as pairing it with our helper functions to make the entire implementation easy or else can be used as a standalone hook. It also has callback functions that can be used to show different messages to the user based on the current state of the hook.

Parameters
NameTypeDescription
containerRefRefObject<HTMLDivElement>A reference to the container element that bounds the resizable component.
resizableRefRefObject<HTMLDivElement>A reference to the element that will be resized.
optionsResizableOptionsAn optional object for configuring resize behavior, including callbacks and dimension limits.

ResizableOptions

NameTypeDefaultDescription
minWidthstring"0px"Minimum width of the resizable element.
minHeightstring"0px"Minimum height of the resizable element.
maxWidthstring"100%"Maximum width of the resizable element.
maxHeightstring"100%"Maximum height of the resizable element.
onResizeStart() => voidnullCallback function to execute when resizing starts.
onResize() => voidnullCallback function to execute while resizing is in progress.
onResizeEnd() => voidnullCallback function to execute when resizing ends.
expandBoundingElementbooleantrueIf false, prevents the resizable element from expanding beyond the container bounds.
Return Table

| Name | Type | Description | | ------------------- | ----------------------------------- | ------------------------------------------------------------------ | -------------------------------------------------------------- | | containerDimensions | { width: number; height: number } | Current dimensions of the resizable container. | | isResizing | boolean | Indicates if the element is currently being resized. | | handleResize | (e, direction) => void | Function to initiate the resize operation on mouse or touch start. | | stopResize | () => void | Function to stop the resize operation on mouse or touch end. | | handleMove | (e: TouchEvent | MouseEvent) => void | Function to handle mouse or touch move events during resizing. |

Bounding Element - can't resize outside this. However it can be expanded but the resize won't work outside this. This property can be adjusted in the options.Arrow icon

This is a resizable container