Resizable
Add resize handles with min/max constraints and aspect ratio lock.
Code
$("#box").resizable({
minHeight: 100,
minWidth: 150,
maxHeight: 400,
maxWidth: 600,
handles: "n, e, s, w, ne, se, sw, nw",
aspectRatio: 4 / 3,
grid: 10,
animate: true,
resize: function(event, ui) {
$("#size-label").text(ui.size.width + "x" + ui.size.height);
},
stop: function(event, ui) {
console.log("Final size:", ui.size, "position:", ui.position);
}
});
// Also resize a sibling element (e.g. mirror image)
$("#image").resizable({
alsoResize: "#image-preview"
});Explanation
Adds eight resize handles to an element with min/max bounds and an optional aspect ratio lock. The ui object passed to event callbacks exposes size, position, originalSize and originalPosition for custom logic. Use alsoResize to keep related elements in sync, and grid to snap to fixed increments.
More jQuery UI Snippets
Draggable
Make elements draggable with axis, containment, and event callbacks.
Droppable
Create drop targets that accept draggable elements with hover and drop events.
Sortable
Reorder list items via drag-and-drop and persist the new order.
Accordion
Collapsible content panels with only one section expanded at a time.
Datepicker
Calendar widget with date range limits, formatting, and inline mode.
Dialog
Modal window with buttons, animations, and dynamic open/close.