Show · Resizable
Resizable
The component size is adjusted based on the user's mouse drag, supporting both resizing of a single component and combined resizing.

Demos

How to import

Single Component

Basic Usage and Callbacks You can set the initial size using defaultSize, and set drag callbacks with onResizeStart, onResize, and onResizeEnd.

Controlling Resize Directions

You can enable or disable specific resizing directions by setting the value of enable. All directions are enabled by default.

Setting Resizing Ratio

You can set the drag and resize ratio using ratio.

Locking Aspect Ratio

You can lock the aspect ratio by setting lockAspectRatio. It can be a boolean or a number. If true, it locks to the initial aspect ratio; if a number, it locks to the given ratio.

Setting Maximum and Minimum Width/Height

You can set the maximum and minimum width and height using maxHeight, maxWidth, minHeight, and minWidth.

Control Width/Height

You can control the size of the element through the size prop.

Setting Scale

You can scale the entire element by setting the scale prop.

Restricting Width/Height by an Element

You can restrict the width and height by setting the boundElement, which supports string values like 'parent' or 'window'.

Customizing Corner Handler Styles

You can customize the drag handles for each direction using handleNode, and apply different styles using handleStyle and handleClassName.

Allowing Incremental Width and Height Adjustment

You can allow gradual adjustments in width and height using the grid and snap properties. The grid property specifies the increments to which resizing should snap. The default value is [1, 1]. The snap property specifies the absolute pixel values to which resizing should snap. Both x and y are optional, allowing you to define only the desired axis. These two parameters can be combined with the snapGap property, which specifies the minimum gap required to move to the next target. The default is 0, meaning the target defined by grid/snap is always used.

Group Component

notice
The parent element of `ResizeGroup` needs to have a size in the main axis direction. It's best not to set padding for ResizeItem, as it may cause the minimum size to not match the expected value. You can set padding for child elements instead.
Use the direction prop to set the resizing direction. Options are horizontal and vertical. Supports onResizeStart, onResize, and onResizeEnd callbacks, as well as setting min and max to control the maximum and minimum width/height.

Nested

Set the resizing direction using the direction prop. Options are horizontal and vertical.

API

Resizable

单个伸缩框组件。
参数说明类型默认值版本
className类名string
sizeControls the size of the resizable box, supports both numeric and string (px/vw/vh/%) formatsSize
defaultSizeSets the initial width and height, supports both numeric and string (px/vw/vh/%) formatsSize
minWidthSpecifies the minimum width of the resizable boxstring | number
maxWidthSpecifies the maximum width of the resizable boxstring | number
minHeightSpecifies the minimum height of the resizable boxstring | number
maxHeightSpecifies the maximum height of the resizable boxstring | number
lockAspectRatioLocks the aspect ratio of the resizable box when true, using the initial width and height as the ratioboolean | number
enableSpecifies the directions in which the resizable box can be resized. If not set, all directions are enabled by defaultEnable
scaleThe scale ratio of the resizable elementnumber1
boundElementRestricts the size of the resizable element within a specific element. Pass "parent" to set the parent element as the bounding elementstring
handleNodeCustom nodes for the drag handles in each directionHandleNode
handleStyleStyles for the drag handles in each directionHandleNode
handleClassClass names for the drag handles in each directionHandleNode
styleCSSProperties
snapGapSpecifies the minimum gap required to snap to the next targetnumber0
snapSpecifies the pixel values to snap to during resizing. Both x and y are optional, allowing the definition of specific axes onlySnapnull
gridSpecifies the increment to align to when resizing[number, number][1,1]
onChangeCallback during the dragging process(e: Event; direction: String;size: Size) => void-
onResizeStartCallback when resizing starts(e: Event; direction: String) => void-
onResizeEndCallback when resizing ends(e: Event; direction: String) => void-

ResizeGroup

参数说明类型默认值版本
classNamestring
directionSpecifies the resize direction within the group'horizontal' | 'vertical''horizontal'

ResizeHandler

参数说明类型默认值版本
classNamestring
styleCSSProperties

ResizeItem

参数说明类型默认值版本
classNamestring
defaultSizeUsed to set the initial width and height. The string supports % and px units, and when the string is a pure number or a number is set directly, it represents the proportional allocation of the remaining space based on the value.string | number
minSpecifies the minimum size of the resizable box (as percentage or pixel)string
maxSpecifies the maximum size of the resizable box (as percentage or pixel)string
styleCSSProperties
onChangeCallback during the dragging process(e: Event; direction: String;size: Size) => void-
onResizeStartCallback when resizing starts(e: Event; direction: String) => void-
onResizeEndCallback when resizing ends(e: Event; direction: String) => void-

Design Tokens