page_header(title:, subtitle: nil) do |header|
header.with_action { … } # one per action, primary last
header.with_filters { … } # search_input, multi_select, period_picker
header.with_tabs(label:) do |tabs|
tabs.with_tab(label, href: nil, count: nil, selected: false)
tabs.with_action { … }
end
end
Keep the same structure on every page so titles, actions and filters never move between views. The subtitle is one line of live context (last sync, today's date). Actions go right, secondary first and the primary last. Filters start with the search field; pickers follow at their natural width.
Notas
Última sincronização: há 5 minutos
<div style="border: 1px solid var(--line)">
<%= page_header(title: "Notas", subtitle: "Última sincronização: há 5 minutos") do |header| %>
<% header.with_action { button "Exportar filtro…", icon: "download" } %>
<% header.with_action { button "Sincronizar", variant: :primary, icon: "refresh" } %>
<% header.with_filters do %>
<%= search_input placeholder: "Buscar por número, chave, nome ou CNPJ" %>
<%= multi_select name: :companies, label: "Empresas", icon: "building",
all_label: "Todas as empresas", none_label: "Nenhuma empresa", many_label: "%{count} empresas",
options: [ { value: 1, label: "Empresa Exemplo Ltda" }, { value: 2, label: "Fictícia Serviços ME" } ] %>
<% end %>
<% header.with_tabs(label: "Tipo de nota") do |tabs| %>
<% tabs.with_tab "Emitidas", count: 1204, selected: true %>
<% tabs.with_tab "Recebidas", count: 318 %>
<% tabs.with_action { button "Colunas", size: :sm, icon: "columns" } %>
<% end %>
<% end %>
</div>
Slots
| Slot | What goes in it |
|---|---|
action | One per action (button, icon_button, popover…), in order |
filters | The filters row: search_input, multi_select, period_picker |
tabs | A tabs component: with_tab(label, href:, count:, selected:) and with_action |