2.1.0
React-Grid-Layout v2.1.0
This release adds powerful new features for large-scale layouts and custom constraints, along with several bug fixes.
✨ New Features
Pluggable Layout Constraints System
A new constraints system allows custom validation and transformation of layout items during drag and resize operations. Build aspect ratio locks, snap-to-grid, boundary restrictions, and more. #2190
import {
createConstraintEnforcer,
aspectRatioConstraint,
positionConstraint,
sizeConstraint
} from "react-grid-layout/core";
const enforcer = createConstraintEnforcer([
aspectRatioConstraint(16 / 9), // Lock to 16:9 ratio
positionConstraint({ minX: 0, maxX: 10 }), // Restrict X position
sizeConstraint({ minW: 2, maxH: 4 }) // Limit dimensions
]);
<GridLayout constraintEnforcer={enforcer} />
Fast Compactors for Large Layouts
New O(n log n) compactors in dramatically improve performance for dashboards with 200+ widgets: