Kanban Board Move Cards
Three columns of task cards you can drag between, or move with arrow keys or a Move button.
AI prompt
Clean UI mockup of a three-column kanban board titled To do, Doing and Done in a light theme, each column a soft grey rounded lane with small cards holding a task title and a coloured label, one card shown mid-drag slightly tilted with a soft shadow over the Doing column which has a dashed blue drop outline, small counters beside column titles, flat modern style. Negative: heavy gradients, clutter, text errors, device frames. Reduced motion: static design.About this pattern
Definition
A kanban board groups tasks into columns by status. Dragging a card to another column is the obvious gesture, but it must not be the only way: touch screens and keyboard users need alternatives. A focusable card that moves with the arrow keys, or a small Move button, keeps the board usable for everyone.
Purpose & UX principles
- Make each column a labelled region and each card focusable.
- Drag with HTML drag and drop or pointer events; highlight the target column while dragging.
- Provide keyboard moves: Left and Right change column, Up and Down reorder.
- Announce each move, for example Moved Fix login to Doing, position 1 of 3.
Interaction states
- Drag cards, or focus a card and use the arrow keys, or press its Move button.
Motion specification
- Cards slide into place over 150ms.
- Reduced motion: no slide.
Responsive behaviour
- Keep a visible Move option on touch devices where native drag is limited.
- Persist the order on the server and allow undo for mistakes.
Code
<div class="bx"><div class="kb" id="kb"></div><p class="out" id="out" role="status"></p></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.kb{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.col{background:#ececea;border-radius:10px;padding:6px;min-height:150px;display:grid;align-content:start;gap:5px;border:2px dashed transparent}.col.ov{border-color:#2f6bff;background:#e5ecfb}.col h4{font-size:11px;font-weight:700;display:flex;justify-content:space-between;padding:2px 4px;color:#555}.cd{background:#fff;border-radius:8px;padding:6px 7px;font-size:12px;display:flex;justify-content:space-between;align-items:center;gap:4px;box-shadow:0 1px 2px rgba(0,0,0,.1);cursor:grab;border-left:3px solid var(--lb)}.cd:focus-visible{outline:2px solid #2f6bff}.cd.dg{opacity:.4}.cd button{font-size:10px;padding:2px 5px;border-radius:5px;border:1px solid var(--line);background:#fafaf8}.cd span{min-width:0;overflow-wrap:anywhere}.out{font-size:12px;color:var(--muted);min-height:16px}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const NM=['To do','Doing','Done'],D=[['Fix login','#e5533d'],['Write docs','#2f6bff'],['Design icons','#1f9d55'],['Review PR','#e8a02d'],['Plan sprint','#7c3aed']];let cols=[[0,1,2],[3],[4]],drag=null;const kb=document.getElementById('kb'),out=document.getElementById('out');
function draw(f){kb.innerHTML=cols.map((c,ci)=>'<div class="col" data-c="'+ci+'" role="group" aria-label="'+NM[ci]+', '+c.length+' cards"><h4>'+NM[ci]+'<span>'+c.length+'</span></h4>'+c.map(id=>'<div class="cd" draggable="true" tabindex="0" data-id="'+id+'" style="--lb:'+D[id][1]+'"><span>'+D[id][0]+'</span><button type="button" data-m="'+id+'" aria-label="Move '+D[id][0]+' to next column" tabindex="-1">\u2192</button></div>').join('')+'</div>').join('');if(f!=null){const e=kb.querySelector('[data-id="'+f+'"]');if(e)e.focus();}}
function find(id){for(let c=0;c<3;c++){const i=cols[c].indexOf(id);if(i>=0)return[c,i];}}
function move(id,c2,i2,say){const [c,i]=find(id);cols[c].splice(i,1);if(i2==null||i2>cols[c2].length)i2=cols[c2].length;cols[c2].splice(i2,0,id);draw(id);out.textContent='Moved '+D[id][0]+' to '+NM[c2]+', position '+(cols[c2].indexOf(id)+1)+' of '+cols[c2].length+'.';}
kb.addEventListener('dragstart',e=>{const c=e.target.closest('.cd');if(!c)return;drag=+c.dataset.id;c.classList.add('dg');e.dataTransfer.setData('text/plain',String(drag));e.dataTransfer.effectAllowed='move';});
kb.addEventListener('dragend',()=>{drag=null;kb.querySelectorAll('.ov,.dg').forEach(e=>e.classList.remove('ov','dg'));});
kb.addEventListener('dragover',e=>{const c=e.target.closest('.col');if(c&&drag!=null){e.preventDefault();kb.querySelectorAll('.ov').forEach(x=>x.classList.remove('ov'));c.classList.add('ov');}});
kb.addEventListener('drop',e=>{const c=e.target.closest('.col');if(c&&drag!=null){e.preventDefault();const id=drag;drag=null;move(id,+c.dataset.c,null);}});
kb.addEventListener('click',e=>{const b=e.target.closest('[data-m]');if(b){const id=+b.dataset.m,[c]=find(id);move(id,(c+1)%3,null);}});
kb.addEventListener('keydown',e=>{const el=e.target.closest('.cd');if(!el||e.target!==el)return;const id=+el.dataset.id,[c,i]=find(id);let h=true;if(e.key==='ArrowRight'&&c<2)move(id,c+1,Math.min(i,cols[c+1].length));else if(e.key==='ArrowLeft'&&c>0)move(id,c-1,Math.min(i,cols[c-1].length));else if(e.key==='ArrowUp'&&i>0)move(id,c,i-1);else if(e.key==='ArrowDown'&&i<cols[c].length-1)move(id,c,i+1);else h=false;if(h)e.preventDefault();});
draw();out.textContent='Drag a card, or focus it and use the arrow keys.';One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Kanban Board Move Cards — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.kb{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.col{background:#ececea;border-radius:10px;padding:6px;min-height:150px;display:grid;align-content:start;gap:5px;border:2px dashed transparent}.col.ov{border-color:#2f6bff;background:#e5ecfb}.col h4{font-size:11px;font-weight:700;display:flex;justify-content:space-between;padding:2px 4px;color:#555}.cd{background:#fff;border-radius:8px;padding:6px 7px;font-size:12px;display:flex;justify-content:space-between;align-items:center;gap:4px;box-shadow:0 1px 2px rgba(0,0,0,.1);cursor:grab;border-left:3px solid var(--lb)}.cd:focus-visible{outline:2px solid #2f6bff}.cd.dg{opacity:.4}.cd button{font-size:10px;padding:2px 5px;border-radius:5px;border:1px solid var(--line);background:#fafaf8}.cd span{min-width:0;overflow-wrap:anywhere}.out{font-size:12px;color:var(--muted);min-height:16px}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="kb" id="kb"></div><p class="out" id="out" role="status"></p></div>
</div>
<script>
const NM=['To do','Doing','Done'],D=[['Fix login','#e5533d'],['Write docs','#2f6bff'],['Design icons','#1f9d55'],['Review PR','#e8a02d'],['Plan sprint','#7c3aed']];let cols=[[0,1,2],[3],[4]],drag=null;const kb=document.getElementById('kb'),out=document.getElementById('out');
function draw(f){kb.innerHTML=cols.map((c,ci)=>'<div class="col" data-c="'+ci+'" role="group" aria-label="'+NM[ci]+', '+c.length+' cards"><h4>'+NM[ci]+'<span>'+c.length+'</span></h4>'+c.map(id=>'<div class="cd" draggable="true" tabindex="0" data-id="'+id+'" style="--lb:'+D[id][1]+'"><span>'+D[id][0]+'</span><button type="button" data-m="'+id+'" aria-label="Move '+D[id][0]+' to next column" tabindex="-1">\u2192</button></div>').join('')+'</div>').join('');if(f!=null){const e=kb.querySelector('[data-id="'+f+'"]');if(e)e.focus();}}
function find(id){for(let c=0;c<3;c++){const i=cols[c].indexOf(id);if(i>=0)return[c,i];}}
function move(id,c2,i2,say){const [c,i]=find(id);cols[c].splice(i,1);if(i2==null||i2>cols[c2].length)i2=cols[c2].length;cols[c2].splice(i2,0,id);draw(id);out.textContent='Moved '+D[id][0]+' to '+NM[c2]+', position '+(cols[c2].indexOf(id)+1)+' of '+cols[c2].length+'.';}
kb.addEventListener('dragstart',e=>{const c=e.target.closest('.cd');if(!c)return;drag=+c.dataset.id;c.classList.add('dg');e.dataTransfer.setData('text/plain',String(drag));e.dataTransfer.effectAllowed='move';});
kb.addEventListener('dragend',()=>{drag=null;kb.querySelectorAll('.ov,.dg').forEach(e=>e.classList.remove('ov','dg'));});
kb.addEventListener('dragover',e=>{const c=e.target.closest('.col');if(c&&drag!=null){e.preventDefault();kb.querySelectorAll('.ov').forEach(x=>x.classList.remove('ov'));c.classList.add('ov');}});
kb.addEventListener('drop',e=>{const c=e.target.closest('.col');if(c&&drag!=null){e.preventDefault();const id=drag;drag=null;move(id,+c.dataset.c,null);}});
kb.addEventListener('click',e=>{const b=e.target.closest('[data-m]');if(b){const id=+b.dataset.m,[c]=find(id);move(id,(c+1)%3,null);}});
kb.addEventListener('keydown',e=>{const el=e.target.closest('.cd');if(!el||e.target!==el)return;const id=+el.dataset.id,[c,i]=find(id);let h=true;if(e.key==='ArrowRight'&&c<2)move(id,c+1,Math.min(i,cols[c+1].length));else if(e.key==='ArrowLeft'&&c>0)move(id,c-1,Math.min(i,cols[c-1].length));else if(e.key==='ArrowUp'&&i>0)move(id,c,i-1);else if(e.key==='ArrowDown'&&i<cols[c].length-1)move(id,c,i+1);else h=false;if(h)e.preventDefault();});
draw();out.textContent='Drag a card, or focus it and use the arrow keys.';
</script>
</body></html>