empty_state(
title = nil,
description: nil,
icon: nil,
size: :md, # or :sm
bordered: false
) do |e|
e.with_action { … }
end
Just a sentence
The smallest form, for places where the context already explains itself.
Nenhuma nota neste filtro.
<%= empty_state "Nenhuma nota neste filtro." %>
Custom text and icon
The title says what is empty ("Nenhuma quest concluída ainda"), the description says why or what will fill it. Pick a Tabler icon for the thing that is missing, not a generic one. Any extra markup in the block goes under the description.
Nenhuma quest concluída ainda
Quando você concluir uma quest, ela aparece aqui com a data de conclusão.
<%= empty_state "Nenhuma quest concluída ainda", icon: "target",
description: "Quando você concluir uma quest, ela aparece aqui com a data de conclusão." %>
With actions
First use and filters that match nothing deserve a way out: one primary action, at most one secondary. bordered: true draws a dashed outline for an empty area inside a page.
Cadastre a primeira empresa
Com o certificado digital da empresa, as notas emitidas e recebidas são baixadas sozinhas.
<%= empty_state "Cadastre a primeira empresa", icon: "building", bordered: true,
description: "Com o certificado digital da empresa, as notas emitidas e recebidas são baixadas sozinhas." do |e| %>
<% e.with_action { button "Adicionar certificado…", variant: :primary, icon: "plus" } %>
<% e.with_action { button "Como funciona", variant: :ghost, icon: "info-circle" } %>
<% end %>
Small
size: :sm for cards and side panels.
Próximos dias
Nada agendado
As missões com data aparecem aqui.
<%= card(title: "Próximos dias", style: "max-width: 360px") do %>
<%= empty_state "Nada agendado", icon: "calendar", size: :sm,
description: "As missões com data aparecem aqui." %>
<% end %>
Options
| Option | What it does |
|---|---|
title | What is empty, as a short sentence |
description | Why it is empty or what will fill it |
icon | Tabler icon of the missing thing, shown in a soft circle |
size | :md (pages, tables) or :sm (cards, side panels) |
bordered | Dashed outline for an empty area inside a page |
Slots
| Slot | What goes in it |
|---|---|
action | Buttons under the text; the first one primary |