Drag & Drop
Live.Dnd lets you build UIs visually. At wider sizes, drag a component from
the left palette onto the canvas, then edit its properties from the panel on
the right; below Live.Dnd's own responsive breakpoint, the palette and
panel move into a drawer instead, and a tap adds the section (there's nothing
visible to drag onto once the canvas is stacked behind the drawer). Powered
by @dnd-kit.
import { useState } from 'react';
import Live from '@jbpark/live-editor';
export default function DragAndDrop() {
const [value, setValue] = useState('');
return (
<Live>
<Live.Dnd
value={value}
onChange={setValue}
dynamicTailwind
frame={{ mode: 'shadow', syncStyle: true }}
/>
</Live>
);
}
value/onChangehold the generated source — drops and property edits are applied through the same AST pipeline, so the code stays canonical.frameconfigures the preview surface (see Preview Modes).- Use
itemsto customize the palette's available sections, andchildrento replace the built-in UI — a region of it (<Live.Dnd.Layout panel={...} />) or the whole arrangement, driven from theuseDndPalette()/useDndPanel()/useDndLayout()hooks — see Custom Palette & Panel.
The embedded demo above runs the real Live.Dnd component, isolated with
shadow mode inside a sandboxed iframe (see
Preview Modes).