09 · Workflow

Kanban

color neutral/info/warning/primary/teal/success · hint empty/always · drag between columns

A board in columns for a workflow (renewals, cases, tasks).

A card being dragged to the next column

A separar2
Balcão
PED-2492 · Padaria Central
PC hoje
Entrega
PED-2495 · Farmácia Vida
FV amanhã
Em rota1
Entrega
PED-2491 · Bom Preço
BP 14h
Entregue1
Balcão
PED-2488 · Serrinha
AS ontem
.heex
<.kanban id="k1" style="--cols:3" local>
  <.kanban_column id="col-A separar" color="neutral" label="A separar" count={2}>
    <:actions><.button canvas appearance="ghost" size="sm" icon aria-label="Adicionar"><.icon name="plus" /></.button></:actions>
    <.kanban_card id="k1-c1" class="relative z-[3] animate-[mo-kmove_6s_cubic-bezier(.5,0,.2,1)_infinite]" style="--kx:calc(100% + 14px)"><div class="flex flex-wrap items-center justify-between gap-2.5"><.badge canvas>Balcão</.badge><.icon name="more-h" size="md" class="text-muted" /></div><b>PED-2492 · Padaria Central</b>
      <div class="flex flex-wrap items-center justify-between gap-2.5"><.avatar initials="PC" size="24" />
        <span class="flex items-center gap-1 text-xs text-muted"><.icon name="calendar" size="sm" />hoje</span></div></.kanban_card>
    <.kanban_card id="k1-c2"><div class="flex flex-wrap items-center justify-between gap-2.5"><.badge canvas color="info">Entrega</.badge><.icon name="more-h" size="md" class="text-muted" /></div><b>PED-2495 · Farmácia Vida</b>
      <div class="flex flex-wrap items-center justify-between gap-2.5"><.avatar initials="FV" size="24" />
        <span class="flex items-center gap-1 text-xs text-muted"><.icon name="calendar" size="sm" />amanhã</span></div></.kanban_card>
    
  </.kanban_column>
  <.kanban_column id="col-Em rota" color="warning" label="Em rota" count={1}>
    <:actions><.button canvas appearance="ghost" size="sm" icon aria-label="Adicionar"><.icon name="plus" /></.button></:actions>
    <.kanban_card id="k1-c3"><div class="flex flex-wrap items-center justify-between gap-2.5"><.badge canvas color="info">Entrega</.badge><.icon name="more-h" size="md" class="text-muted" /></div><b>PED-2491 · Bom Preço</b>
      <div class="flex flex-wrap items-center justify-between gap-2.5"><.avatar initials="BP" size="24" />
        <span class="flex items-center gap-1 text-xs text-muted"><.icon name="calendar" size="sm" />14h</span></div></.kanban_card>
    
  </.kanban_column>
  <.kanban_column id="col-Entregue" color="success" label="Entregue" count={1}>
    <:actions><.button canvas appearance="ghost" size="sm" icon aria-label="Adicionar"><.icon name="plus" /></.button></:actions>
    <.kanban_card id="k1-c4"><div class="flex flex-wrap items-center justify-between gap-2.5"><.badge canvas>Balcão</.badge><.icon name="more-h" size="md" class="text-muted" /></div><b>PED-2488 · Serrinha</b>
      <div class="flex flex-wrap items-center justify-between gap-2.5"><.avatar initials="AS" size="24" />
        <span class="flex items-center gap-1 text-xs text-muted"><.icon name="calendar" size="sm" />ontem</span></div></.kanban_card>
    
  </.kanban_column>
</.kanban>

column color · hint

neutral1
Tag
Pedido
AN hoje
info1
Tag
Pedido
AN hoje
warning0
Solte aqui
primary0
Solte aqui
teal0
Solte aqui
success0
Solte aqui
.heex
<.kanban id="k2" style="--cols:3" local>
  <.kanban_column id="col-neutral" color="neutral" label="neutral" count={1}>
    <:actions><.button canvas appearance="ghost" size="sm" icon aria-label="Adicionar"><.icon name="plus" /></.button></:actions>
    <.kanban_card id="k2-c1"><div class="flex flex-wrap items-center justify-between gap-2.5"><.badge canvas>Tag</.badge><.icon name="more-h" size="md" class="text-muted" /></div><b>Pedido</b>
      <div class="flex flex-wrap items-center justify-between gap-2.5"><.avatar initials="AN" size="24" />
        <span class="flex items-center gap-1 text-xs text-muted"><.icon name="calendar" size="sm" />hoje</span></div></.kanban_card>
    
  </.kanban_column>
  <.kanban_column id="col-info" color="info" label="info" count={1}>
    <:actions><.button canvas appearance="ghost" size="sm" icon aria-label="Adicionar"><.icon name="plus" /></.button></:actions>
    <.kanban_card id="k2-c2"><div class="flex flex-wrap items-center justify-between gap-2.5"><.badge canvas>Tag</.badge><.icon name="more-h" size="md" class="text-muted" /></div><b>Pedido</b>
      <div class="flex flex-wrap items-center justify-between gap-2.5"><.avatar initials="AN" size="24" />
        <span class="flex items-center gap-1 text-xs text-muted"><.icon name="calendar" size="sm" />hoje</span></div></.kanban_card>
    
  </.kanban_column>
  <.kanban_column id="col-warning" color="warning" label="warning" count={0}>
    <:actions><.button canvas appearance="ghost" size="sm" icon aria-label="Adicionar"><.icon name="plus" /></.button></:actions>
    
    <:empty>Solte aqui</:empty>
  </.kanban_column>
  <.kanban_column id="col-primary" color="primary" label="primary" count={0}>
    <:actions><.button canvas appearance="ghost" size="sm" icon aria-label="Adicionar"><.icon name="plus" /></.button></:actions>
    
    <:empty>Solte aqui</:empty>
  </.kanban_column>
  <.kanban_column id="col-teal" color="accent" label="teal" count={0}>
    <:actions><.button canvas appearance="ghost" size="sm" icon aria-label="Adicionar"><.icon name="plus" /></.button></:actions>
    
    <:empty>Solte aqui</:empty>
  </.kanban_column>
  <.kanban_column id="col-success" color="success" label="success" count={0}>
    <:actions><.button canvas appearance="ghost" size="sm" icon aria-label="Adicionar"><.icon name="plus" /></.button></:actions>
    
    <:empty>Solte aqui</:empty>
  </.kanban_column>
</.kanban>

Usage

<.kanban columns={@stages} items={@deals} on_move="move" />

Rules

  • A column is a tray (lu-card without an overline title); the dragged card tilts 2° with an md shadow.
  • Count and value sum at the top of each column.

API reference

Todos os function components, atributos, valores e slots que este componente cobre.

Kanban board: a row of tinted columns holding cards that are dragged between them.

<.kanban id="funnel" event="move" aria-label="Sales funnel" style="--cols:3">
  <.kanban_column id="col-open" list="open" label="Open" count={length(@open)} color="primary">
    <.kanban_card :for={card <- @open} id={"card-#{card.id}"} item={card.id}>
      <b>{card.title}</b>
    </.kanban_card>
    <:empty>Drop here</:empty>
  </.kanban_column>
  <.kanban_lost label="Lost" count={3} list="lost" />
</.kanban>

Styled only with Tailwind utilities. The board is one LedgerUI.Sortable hook (priv/static/ledger_ui/hooks/sortable.js): columns (data-part="kanban-column") are lists, cards (data-part="kanban-card") are items, and a drop pushes event (to target when given) with %{"id" => item, "from" => list, "to" => list, "index" => position}. Nothing is moved in the browser: the server's render is the new order. data-list/data-id are only rendered when list/item are given; the hook falls back to the element ids.

A column with a limit turns its pill and bar red (data-wip="exceeded") when count goes over it. The board is role="group" when it has an aria-label. --cols in style sets the grid columns; without it the columns are 272px wide in a row that scrolls sideways (fluid shares the width instead).

The same hook sorts any list: put phx-hook="LedgerUI.Sortable" on it with data-list, data-event, data-group, data-handle, data-axis, data-target, data-disabled; items carry data-id.

<.kanban>

Attr Type Default Values / notes
id (required) :string
event :string nil
target :any nil
group :string nil
disabled :boolean false
local :boolean false The board moves the dropped card itself (and the counters), besides pushing event.
fluid :boolean false
active :string nil Phone mode: the column shown below 640px.
class :any nil

Any other HTML/phx attribute goes to the root element.

Slots:

  • <:inner_block> (required)

<.kanban_column>

Attr Type Default Values / notes
id (required) :string
list :string nil
label (required) :string
count :any nil
count_label :string nil
over_limit :boolean false
hint :string "empty" empty, always
active :boolean false
color :string nil nil, neutral, info, warning, primary, accent, success
limit :integer nil
meta :string nil
total :string nil
progress :integer nil
disabled :boolean false
class :any nil

Any other HTML/phx attribute goes to the root element.

Slots:

  • <:actions>
  • <:empty> - attrs: title, icon
  • <:footer>
  • <:icon>
  • <:inner_block>

<.kanban_card>

Attr Type Default Values / notes
id (required) :string
item :any nil
risk :boolean false
dense :boolean false
grip :boolean false
class :any nil

Any other HTML/phx attribute goes to the root element.

Slots:

  • <:actions>
  • <:inner_block> (required)

<.kanban_lost>

Attr Type Default Values / notes
label (required) :string
count :integer nil
meta :string nil
list :string nil
class :any nil

Any other HTML/phx attribute goes to the root element.

Slots:

  • <:icon>