
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
web-draggable
Advanced tools
A lightweight, framework-agnostic drag and drop library built with Web Components and TypeScript.
# Using Bun
bun add web-draggable
# Using npm
npm install web-draggable
# Using pnpm
pnpm add web-draggable
<!DOCTYPE html>
<html>
<head>
<style>
draggable-element {
display: block;
padding: 1rem;
background: #667eea;
color: white;
border-radius: 4px;
cursor: move;
}
draggable-element.dragging {
opacity: 0.5;
}
droppable-zone {
display: block;
min-height: 200px;
padding: 1rem;
border: 2px dashed #ccc;
border-radius: 4px;
}
droppable-zone.drag-over {
border-color: #667eea;
background: #f0f4ff;
}
</style>
</head>
<body>
<draggable-element drag-data='{"id": 1}'>
Drag me!
</draggable-element>
<droppable-zone id="drop-zone">
Drop here
</droppable-zone>
<script type="module">
import 'web-draggable';
document.addEventListener('drop-element', (e) => {
const { draggedElement, droppedOn, data } = e.detail;
droppedOn.appendChild(draggedElement);
console.log('Dropped:', data);
});
</script>
</body>
</html>
import { DraggableElement, DroppableZone, type DropEventDetail } from 'web-draggable';
// Listen to drop events
document.addEventListener('drop-element', (e: CustomEvent<DropEventDetail>) => {
const { draggedElement, droppedOn, data } = e.detail;
console.log('Element dropped:', data);
});
// Programmatically set data
const draggable = document.querySelector('draggable-element') as DraggableElement;
draggable.setData({ id: 123, name: 'My Item' });
This library is fully accessible with keyboard navigation and screen reader support.
See examples/accessible.html for a complete accessible implementation.
You can restrict which elements can be dropped in which zones using the group system. This is useful for creating multiple independent drag & drop contexts on the same page.
drag-group attribute to draggable elementsaccept-group attribute to droppable zonesaccept-group="work,personal")<!-- Work tasks - can only be dropped in work zones -->
<draggable-element drag-group="work">
Complete project proposal
</draggable-element>
<!-- Personal tasks - can only be dropped in personal zones -->
<draggable-element drag-group="personal">
Buy groceries
</draggable-element>
<!-- Urgent tasks -->
<draggable-element drag-group="urgent">
Critical bug fix
</draggable-element>
<!-- Work zone - only accepts work items -->
<droppable-zone accept-group="work">
<!-- Work items go here -->
</droppable-zone>
<!-- Personal zone - only accepts personal items -->
<droppable-zone accept-group="personal">
<!-- Personal items go here -->
</droppable-zone>
<!-- Mixed zone - accepts both work and personal items -->
<droppable-zone accept-group="work,personal">
<!-- Both work and personal items can be dropped here -->
</droppable-zone>
<!-- Priority zone - accepts work and urgent items -->
<droppable-zone accept-group="work,urgent">
<!-- Work and urgent items can be dropped here -->
</droppable-zone>
Important: If an element has a drag-group but no zone has the matching accept-group, it cannot be dropped anywhere. Similarly, if a zone has an accept-group but the element has no drag-group, the drop will be rejected.
See examples/groups.html for a complete demonstration.
<draggable-element>A custom element that can be dragged.
drag-data - JSON string containing custom data to attach to the drag operationdrag-group - Optional group identifier. When specified, this element can only be dropped in zones with a matching accept-group attributedrag-handle - Optional CSS selector for a drag handle element within the draggable elementdrag-start - Fired when dragging startsdrag-end - Fired when dragging endssetData(data: Record<string, unknown>) - Set custom data for the drag operationgetData(): Record<string, unknown> - Get the custom data<droppable-zone>A custom element that accepts dropped elements.
accept-group - Optional group identifier. When specified, this zone only accepts draggable elements with a matching drag-group attributearia-label - Optional label for screen readers to describe the drop zonedrag-over - Fired when a draggable element is over the zonedrop-element - Fired when an element is droppeddrag-over - Applied when a draggable element is over the zonedragging - Applied to draggable elements while being dragged# Install dependencies
bun install
# Check formatting and linting
bun run check
# Build the library
bun run build
# View the demo (requires a local server)
# Open examples/index.html in your browser
MIT
FAQs
A lightweight drag and drop library using Web Components
We found that web-draggable demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.