08 · Tabelas

BulkBar

Barra inline no topo da tabela durante a seleção

Substitui a toolbar pela barra de ações em massa enquanto há linhas selecionadas.

Contador subindo enquanto marca

Selecionar todas as 1.096
.heex
<%!-- contador subindo enquanto marca: faixa inline do canvas, contagem animada só com CSS (mo-count, em loop) --%>
<div class="flex items-center gap-2.5 rounded-lg border border-[color-mix(in_oklab,var(--lu-accent)_30%,transparent)] bg-accent-soft px-2.5 py-2">
  <.checkbox id="bulk-count-check" color="primary" aria-label="Seleção" checked indeterminate />
  <b class="font-semibold tabular-nums [--to:25] [--suf:'_selecionadas'] animate-[mo-count_5s_cubic-bezier(.2,.8,.2,1)_infinite] after:[counter-reset:n_var(--lu-n)] after:content-[var(--pre,'')_counter(n)_var(--suf,'')]"></b>
  <a href="#" class="text-[13px] font-medium text-accent-content hover:underline hover:underline-offset-[3px]">Selecionar todas as 1.096</a>
  <span class="min-w-0 flex-1"></span>
  <.button canvas size="sm"><.icon name="folder" />Mover</.button>
  <.button canvas size="sm"><.icon name="download" />Exportar</.button>
  <.button canvas size="sm" color="error"><.icon name="trash" />Excluir</.button>
</div>

bulk_bar inline: contagem, selecionar todas e ações (Excluir em danger)

25 selecionadas Selecionar todas as 1096
.heex
<%!-- bulk_bar inline: a faixa no topo da tabela com o componente real (25 selecionadas, selecionar todas, Mover, Exportar e Excluir em danger), entrando em loop --%>
<div class="rounded-xl bg-tray p-4">
  <.bulk_bar id="bulk-loop" variant="inline" count={25} total={1096} label="selecionada" label_plural="selecionadas" on_select_all="select_all" select_all_label="Selecionar todas as %{total}" floating={false} class="animate-[mo-sel_6s_cubic-bezier(.2,.8,.2,1)_infinite]">
    <:action icon="folder">Mover</:action>
    <:action icon="download">Exportar</:action>
    <:action variant="danger" icon="trash">Excluir</:action>
  </.bulk_bar>
</div>

variant="float": pílula escura no centro inferior de um container posicionado

3 selecionados
.heex
<%!-- float: pílula escura no centro inferior do container posicionado (relative + altura fixa) --%>
<div class="relative h-[200px] overflow-hidden rounded-xl bg-tray">
  <.bulk_bar id="bulk-float-static" variant="float" count={3} label="selecionado" label_plural="selecionados" on_clear="clear" clear_label="Limpar seleção">
    <:action icon="folder" title="Mover"><span class="max-sm:hidden">Mover</span></:action>
    <:action icon="download" title="Exportar"><span class="max-sm:hidden">Exportar</span></:action>
    <:action variant="danger" icon="trash" title="Excluir"><span class="max-sm:hidden">Excluir</span></:action>
  </.bulk_bar>
</div>

Experimente: selecionar todos, limpar (Esc), ação desabilitada e excluir com confirmação

PED-2491 Mercadinho Bom Preço R$ 1.284,90
PED-2492 Padaria Central R$ 312,00
PED-2493 Farmácia Vida R$ 2.940,10
PED-2494 Açougue Serrinha R$ 860,00
PED-2495 Empório do Vale R$ 475,50
PED-2496 Quitanda Aurora R$ 198,00
Marque linhas para ver a barra.
.heex
<%!-- confirmação: selecionar todos, limpar (x ou Esc), ação desabilitada e Excluir com confirmação que remove as linhas --%>
<.live_component module={LedgerShowcaseWeb.Demos.BulkBarDemo} id="bulk-confirm" mode={:confirm} />

Experimente: ação em massa com progress e progress_max

PED-2491 Mercadinho Bom Preço R$ 1.284,90
PED-2492 Padaria Central R$ 312,00
PED-2493 Farmácia Vida R$ 2.940,10
PED-2494 Açougue Serrinha R$ 860,00
PED-2495 Empório do Vale R$ 475,50
PED-2496 Quitanda Aurora R$ 198,00
Marque linhas para ver a barra.
.heex
<%!-- progresso: ação em massa com progress/progress_max (job simulado), show_esc e reset ao terminar --%>
<.live_component module={LedgerShowcaseWeb.Demos.BulkBarDemo} id="bulk-progress" mode={:progress} />

Experimente: variant="float" interativo

PED-2491 Mercadinho Bom Preço R$ 1.284,90
PED-2492 Padaria Central R$ 312,00
PED-2493 Farmácia Vida R$ 2.940,10
PED-2494 Açougue Serrinha R$ 860,00
PED-2495 Empório do Vale R$ 475,50
PED-2496 Quitanda Aurora R$ 198,00
Marque linhas para ver a barra.
.heex
<%!-- float interativo: variant="float" em container posicionado; a ação roda na hora, sem confirmação --%>
<.live_component module={LedgerShowcaseWeb.Demos.BulkBarDemo} id="bulk-float" mode={:float} />

bulk_bar floating={false}: a barra que sobe quando há seleção (antes selection_bar)

3 selecionados
.heex
<div style="height:110px;position:relative;overflow:hidden;border-radius:14px;background:var(--lu-bg-tray)">
  <div style="position:absolute;left:0;right:0;bottom:16px;display:flex;justify-content:center">
    <.bulk_bar id="sel-live" count={3} label="selecionado" label_plural="selecionados" floating={false} class="animate-[mo-sel_6s_cubic-bezier(.2,.8,.2,1)_infinite]">
      <:action icon="file">Emitir NF-e</:action>
        <:action icon="download">Exportar</:action>
        <:action variant="danger" icon="trash">Excluir</:action>
    </.bulk_bar>
  </div>
</div>

bulk_bar variant inverse · soft · solid

inverse
3 selecionados
soft
3 selecionados
solid
3 selecionados
.heex
<div class="flex flex-col gap-2.5">
  <div :for={v <- ~w(inverse soft solid)} class="flex flex-wrap items-center gap-2.5">
    <span class="font-mono text-xs text-muted" style="width:60px">{v}</span>
    <.bulk_bar id={"sel-" <> v} variant={v} count={3} label="selecionado" label_plural="selecionados" floating={false}>
      <:action icon="file">Emitir NF-e</:action>
        <:action icon="download">Exportar</:action>
        <:action variant="danger" icon="trash">Excluir</:action>
    </.bulk_bar>
  </div>
</div>

Uso

<.bulk_bar count={3} total={1096} />

Regras

  • Ofereça “selecionar todas as 1.096” quando a página inteira estiver marcada.

Referência da API

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

The bar of bulk actions for a table with selection: how many are selected, optional fields, buttons for the actions and a close that clears the selection. It shows only while count is above zero.

<.bulk_bar
  id="orders-bulk"
  count={@count}
  label="selecionado"
  label_plural="selecionados"
  total={@total}
  on_select_all="select_all"
  on_clear="clear_selection"
>
  <:action icon="file" phx-click="issue">Emitir NF-e</:action>
  <:action icon="download" phx-click="export">Exportar</:action>
  <:action variant="danger" icon="trash" phx-click="delete" confirm="Excluir 3 pedidos?"
    confirm_text="Os rascunhos somem para todos." confirm_label="Excluir" cancel_label="Cancelar">
    Excluir
  </:action>
</.bulk_bar>

Texts come from outside (label, label_plural, select_all_label with %{total}, clear_label); nothing is pluralized here.

Looks

  • inverse (default), soft and solid: the selection pill (dark, accent-soft and accent).
  • inline: the strip at the top of a table (a panel tinted with the accent): a checkbox that clears the selection, the count, "select all" and the buttons.

  • float (the canvas template's bar): a dark pill absolutely positioned at the bottom center of the closest positioned ancestor (the app shell), with the count, one :action per button (variant="danger" is red and set apart by a rule) and the close. It ignores floating, progress and the confirm of an action (the action runs at once).

floating (default) pins a pill to the bottom center of the viewport; floating={false} lays it out where it is (a bar inside a card or a toolbar). progress/progress_max turn the bar into a progress bar while a bulk action runs. Esc runs on_clear (phx-window-keydown).

An :action with confirm opens a small card first (above the bar when floating, below otherwise); only its confirm button runs the action's phx-click. A disabled action keeps the focus (aria-disabled) and renders no phx-* attributes.

Styled only with Tailwind utilities.

<.bulk_bar>

Attr Type Default Values / notes
id (required) :string
count (required) :integer How many are selected; the bar shows only above zero.
label :string "selected" The text after the count, for one selected.
label_plural :string nil
total :integer nil How many there are in all (every page).
select_all_label :string "Select all %{total}"
on_clear :any nil
on_select_all :any nil
target :any nil
clear_label :string "Clear selection"
check_label :string "Selection" aria-label of the inline checkbox.
show_esc :boolean false
variant :string "inverse" inverse, soft, solid, inline, float
floating :boolean true
progress :integer nil
progress_max :integer nil
class :any nil

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

Slots:

  • <:action> - attrs: variant, disabled, icon, confirm, confirm_text, confirm_label, cancel_label, id, title, aria-label, phx-click, phx-target, phx-disable-with, phx-value-id - A button.
  • <:field> - A control (a select, an input) in the bar.