Menu

A kanban board in React with native drag and drop (and a fallback that works on phones)
📰

A kanban board in React with native drag and drop (and a fallback that works on phones)

DEV Community: react·Bon·9 days ago
#msYBDCAJ
#devtoreact#devto#dev#stage#move
Reading 0:00
15s threshold

I recently built Tandem , a CRM dashboard template with Next.js 16 and Tailwind CSS 4. The centerpiece is a kanban pipeline: deals move from Lead to Won. I wanted it without a drag-and-drop library, and I wanted it to work for people who can't drag. Here is the whole approach.

1. State: one array, stage is just a field

Columns don't own their cards. There is one list of deals, and a column is a filter:

const [ deals , setDeals ] = useState ( initialDeals );

function move ( id : string , stage : StageId ) { setDeals (( list ) => list . map (( d ) => ( d . id === id ? { ... d , stage } : d ))); }

// in render stages . map (( s ) => { const list = visible . filter (( d ) => d . stage === s . id ); // ... });

Enter fullscreen mode

Exit fullscreen mode

Moving a card is a single map . Totals per column, the weighted forecast and filters all fall out of the same array for free.

2. Native HTML drag and drop

The browser already has drag and drop.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.