Live Demo
Drag the bottom-right (and other) handles of the box below to resize it live. Size and last event are shown underneath.
Try resizing the box above.
jQuery UI's resizable() interaction turns any element into a box the user can drag-resize from its edges or corners. It's built on top of jQuery, adding ready-made handles, ratio locking, size limits, and resize events so you don't have to build the drag math yourself.
| Option / Event | Description | Example |
|---|---|---|
.resizable() | Turns the element into a resizable box with a default corner handle. | $('#box').resizable(); |
handles | Which edges/corners show handles: n, e, s, w, ne, se, sw, nw. | handles: 'n, e, s, w, ne, se, sw, nw' |
aspectRatio | Lock width/height proportions while resizing (useful for images). | aspectRatio: true |
minWidth / minHeight | Smallest size the box can shrink to. | minWidth: 100, minHeight: 80 |
maxWidth / maxHeight | Largest size the box can grow to. | maxWidth: 400, maxHeight: 300 |
start | Fires once when a resize drag begins. | start: function(e, ui){ ... } |
resize | Fires continuously while dragging. | resize: function(e, ui){ ... } |
stop | Fires once when the resize drag ends. | stop: function(e, ui){ ... } |
jquery-ui.css) so resize handles are visible; without it the handles still work but render invisibly at the edges.aspectRatio (Lock Proportions)
// great for resizing images without distortion
$('#img').resizable({
aspectRatio: true
});
$('#box').resizable({
minWidth: 100,
minHeight: 80,
maxWidth: 400,
maxHeight: 300
});
start, resize, stop
$('#box').resizable({
start: function(e, ui){ // drag begins },
resize: function(e, ui){ // while dragging, ui.size.width/height },
stop: function(e, ui){ // drag ends }
});
Drag the bottom-right (and other) handles of the box below to resize it live. Size and last event are shown underneath.
resizable() with draggable() on the same element to build movable, resizable panels/widgets (e.g. a dashboard card).