JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://gridstackjs.com/node_modules/gridstack/dist/gridstack-h5.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://gridstackjs.com/demo/demo.css">
<body>
<h1>Advanced Demo</h1>
<div class="row">
<div class="col-md-2 d-none d-md-block">
<div id="trash" style="padding: 5px; margin-bottom: 15px;" class="text-center">
<div>
<ion-icon name="trash" style="font-size: 300%"></ion-icon>
</div>
<div>
<span>Drop here to remove!</span>
</div>
</div>
<div class="newWidget grid-stack-item">
<div class="grid-stack-item-content" style="padding: 5px;">
<div>
<ion-icon name="add-circle" style="font-size: 300%"></ion-icon>
</div>
<div>
<span>Drag me in the dashboard!</span>
</div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-10">
<div class="grid-stack"></div>
</div>
</div>
<script type="text/javascript">
let grid = GridStack.init({
cellHeight: 70,
acceptWidgets: true,
dragIn: '.newWidget', // class that can be dragged from outside
dragInOptions: { revert: 'invalid', scroll: false, appendTo: 'body', helper: 'clone' }, // clone or can be your function
removable: '#trash', // drag-out delete class
});
let items = [
{x: 10, y: 0, w: 2, h: 2, content: '4'},
{x: 0, y: 2, w: 2, h: 2, content: '5'},
{x: 2, y: 2, w: 2, h: 4, content: '6'},
];
grid.load(items);
grid.on('dropped', function(event, previousWidget, newWidget) {
setTimeout(function () {
grid.update(newWidget.el, {resizeHandles: "e,w", w:1,h:1});
}, 200);
});
</script>
</body>