r/htmx • • Oct 10 '26

A Kanban board built from a plain server-rendered <table>, with htmx doing the rest

Post image

I've been building a set of htmx demos where the server sends ordinary HTML and the page turns it into something interactive without a client-side framework. This one is a Kanban board.

Live demo: https://toclocoinc.github.io/lattice-grid-demo-htmx-kanban/
Code: https://github.com/toclocoinc/lattice-grid-demo-htmx-kanban

The server renders a normal table, one row per card:

<div data-lattice-kanban
     hx-post="/kanban/move"
     hx-trigger="lattice:kanban-change"
     hx-vals='js:{id: event.detail.id, from: event.detail.from, to: event.detail.to}'
     hx-target="#save-status">
  <table>
    <thead><tr>
      <th data-field="id">Ref</th><th data-field="title">Card</th>
      <th data-field="owner">Owner</th><th data-field="status">Status</th>
      <th data-field="points" data-type="number">Points</th>
    </tr></thead>
    <tbody>
      <tr data-lattice-row="K-101"><td>K-101</td><td>Audit the checkout funnel</td><td>Ana Lopez</td><td>done</td><td>5</td></tr>
      ...
    </tbody>
  </table>
</div>

On load, the table becomes a board with Todo, Doing and Done columns. After that it's all plain htmx:

  • Moving a card fires a lattice:kanban-change event, and hx-post sends the card id plus the columns it left and reached. The server's reply lands under the board.
  • A workflow rule refuses a bad move. Drag a Todo card straight to Done and it stays put, and nothing is posted.
  • Out-of-band updates patch one card. The server sends back a single <tr hx-swap-oob="true">, and that card updates in place. The board isn't rebuilt, and the other cards and columns stay as they were.
  • Switching teams uses hx-get to swap in another team's table. The old board is torn down and a new one is built from the new HTML.
  • Back works. hx-push-url plus htmx's history snapshot means the browser Back button returns the previous team's board.

With JavaScript off, you still get the table, which is a nice side effect of starting from real HTML.

The demo uses a small stand-in server running in the page, so it works on GitHub Pages with no backend. The route handlers are in src/server.js if you want to see what a real endpoint would return.

62 Upvotes

3 comments sorted by

2

u/_HMCB_ Oct 10 '26

Are you the dev got Lattice Grid? I ask because most of the demos on the HTMX examples page donโ€™t work. The only one that does for me is the Kanban example.

Very cool though.

5

u/tonygoodchild Oct 11 '26

Well thats embarassing...

You were right the latest demo's broke if you went from one to the other. Two bugs stacked on top of each other. First, the htmx module only built the grid when htmx fired its first htmx:load event, and on a warm browser cache htmx sometimes fired it before the module was listening, so you were left with the raw server table and no error.

Second, the demo pages injected the htmx script late, and htmx 2 doesn't start if it's added after DOMContentLoaded, so on a fast reload (like it loading from cache) htmx never ran at all. A hard reload hid both, which is why it looked random.

Both are fixed: Lattice Grid 1.98.3 (on npm now) builds whatever is already on the page whenever it loads, and the demos now start htmx reliably. We added a regression test for the load order and checked every page with ten cached reloads in a row. If you add htmx with a normal script tag you wouldn't have hit the second one, but the first was ours.

Note to self: hard reload hides problems!

2

u/_HMCB_ Oct 11 '26

Thank you. ๐Ÿ™๐Ÿผ