12 · Sobreposições

Sheet

Folha inferior com alça (mobile e painéis rápidos)

Painel que sobe da base, para mobile e ações rápidas.

Subindo da base

.heex
<div class="relative overflow-hidden rounded-[14px] bg-page shadow-[inset_0_0_0_1px_var(--lu-line)] h-[240px] max-w-[420px] [&>[data-part=drawer-overlay]]:absolute [&>[data-part=drawer-overlay]]:inset-0 [&>[data-part=drawer-overlay]]:rounded-none [&>[data-part=drawer-overlay]]:p-0">
  <div class="absolute inset-0 flex flex-col gap-2.5 px-[18px] py-4"><.skeleton animation={nil} class="h-[9px] w-[38%] rounded-[5px]" /><.skeleton animation={nil} class="h-[9px] w-[70%] rounded-[5px]" /><.skeleton animation={nil} class="h-[9px] w-[55%] rounded-[5px]" /><.skeleton animation={nil} class="h-[9px] w-[62%] rounded-[5px]" /></div>
  <.sheet inline id="sheet-demo" placement="bottom" title="Filtros" close_button={false} class="animate-[lu-drb_4s_cubic-bezier(.2,.8,.2,1)_infinite]">
    <.skeleton animation={nil} class="h-[7px] w-[90%] rounded-sm" /><.skeleton animation={nil} class="h-[7px] w-[70%] rounded-sm" />
    <:footer><.button color="neutral" variant="soft" size="xs">Cancelar</.button><.button color="neutral" size="xs">Salvar</.button></:footer>
  </.sheet>
</div>

Experimente: abre a folha de verdade

.heex
<div class="flex flex-wrap items-center gap-2.5">
  <.button color="neutral" variant="outline" size="sm" aria-haspopup="dialog" aria-controls="sheet-live" phx-click={LedgerUI.open("sheet-live")}><.icon name="filter" />Abrir filtros</.button>
  <.sheet id="sheet-live" placement="bottom" title="Filtros" description="Refine a lista de pedidos.">
    <p class="m-0 text-[14px] text-muted">A folha sobe da base. Feche pelo ×, pelo Esc ou clicando no fundo.</p>
    <:footer>
      <.button color="neutral" variant="soft" size="sm" phx-click={LedgerUI.close("sheet-live")}>Cancelar</.button>
      <.button color="neutral" size="sm" phx-click={LedgerUI.close("sheet-live")}>Aplicar</.button>
    </:footer>
  </.sheet>
</div>

Experimente: size="auto" e width num sheet à direita

.heex
<% items = [%{n: "PED-2491", c: "Mercadinho Bom Preço", f: "Boleto 30/60/90", v: "Rota Sul", d: "12/11/2026", t: "R$ 1.284,90"}, %{n: "PED-2492", c: "Padaria Central", f: "Pix", v: "Rota Norte", d: "13/11/2026", t: "R$ 312,00"}, %{n: "PED-2493", c: "Farmácia Vida", f: "Cartão 3x", v: "Rota Sul", d: "14/11/2026", t: "R$ 2.940,10"}] %>
<div class="flex flex-wrap items-center gap-2.5">
  <.button color="neutral" variant="outline" size="sm" aria-haspopup="dialog" aria-controls="sheet-auto" phx-click={LedgerUI.open("sheet-auto")}>placement="right" · size="auto"</.button>
  <.button color="neutral" variant="soft" size="sm" aria-haspopup="dialog" aria-controls="sheet-width" phx-click={LedgerUI.open("sheet-width")}>{"placement=\"right\" · width={640}"}</.button>

  <.sheet id="sheet-auto" placement="right" size="auto" title="Itens do pedido" description='sheet com size="auto"'>
    <.table id="sheet-auto-t" rows={items} variant="basic">
      <:col :let={o} label="Pedido" class="font-mono text-[13px] whitespace-nowrap">{o.n}</:col>
      <:col :let={o} label="Cliente" class="whitespace-nowrap">{o.c}</:col>
      <:col :let={o} label="Pagamento" class="whitespace-nowrap">{o.f}</:col>
      <:col :let={o} label="Rota" class="whitespace-nowrap">{o.v}</:col>
      <:col :let={o} label="Entrega" class="whitespace-nowrap">{o.d}</:col>
      <:col :let={o} label="Total" align="right" class="font-medium whitespace-nowrap text-ink">{o.t}</:col>
    </.table>
    <:footer>
      <.button color="neutral" variant="soft" size="sm" phx-click={LedgerUI.close("sheet-auto")}>Fechar</.button>
    </:footer>
  </.sheet>
  <.sheet id="sheet-width" placement="right" width={640} title="Pedido #2491" description="sheet com width={640}">
    <p class="m-0 text-[14px] text-muted">O sheet aceita o mesmo <code class="font-mono text-xs">size</code> e <code class="font-mono text-xs">width</code> do drawer; o <code class="font-mono text-xs">placement</code> padrão dele é <code class="font-mono text-xs">bottom</code>, que ocupa a largura da tela.</p>
    <:footer>
      <.button color="neutral" variant="soft" size="sm" phx-click={LedgerUI.close("sheet-width")}>Fechar</.button>
    </:footer>
  </.sheet>
</div>

Uso

<.sheet id="filters" placement="bottom">…</.sheet>

Regras

  • Alça 40×4 no topo; arrastar para baixo fecha.
  • Altura máxima 85% da tela.

Referência da API

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

Side panel (<.drawer>) and its sheet parts (<.sheet_header>, <.sheet_body>, <.sheet_footer>).

<.drawer id="customer" placement="right" size="md" title="New customer" description="Who buys from you.">
  <.form for={@form} id="customer-form" phx-submit="save">...</.form>
  <:footer>
    <.button variant="ghost" phx-click={LedgerUI.close("customer")}>Cancel</.button>
    <.button type="submit" form="customer-form" variant="primary">Save</.button>
  </:footer>
</.drawer>

The title is either title="New customer" or the <:title> slot (markup).

A bare drawer is a sliding frame for a menu; with title, :header or :footer (or variant) it is a sheet: header, scrolling body and fixed footer. placement="bottom" is the phone's sheet (rounded top, grab handle). It opens and closes like LedgerUI.Components.Modal (LedgerUI.open/close/toggle, open, on_open, on_close) through the LedgerUI.Overlay hook; by default it does not lock the page's scroll (lock_scroll).

Keep class and panel_class free of transform, filter and contain, so a modal rendered inside the drawer still covers the whole viewport.

layout="page" is the sheet of the app templates: it renders only while open, as a dim lu-overlay and an aside.lu-drawer laid over the closest positioned ancestor (the app shell), with no hook; the page owns the state. The overlay, the Esc key and the × push on_close. The :header slot is then the content before the ×, :footer the <footer>:

<.drawer :if={@order} id="order" layout="page" open on_close="close_order">
  <:header><div><h3>Pedido #2495</h3><p>Criado hoje</p></div></:header>
  ...body...
  <:footer><.button>Imprimir</.button></:footer>
</.drawer>

inline renders it in the page flow (a static preview, always open, without the hook).

Width

size picks a fixed width (sm 400 px, md, lg, wide 800 px, xl 1080 px). Two ways to take another:

size="auto": the panel is as wide as its content (w-max), at least the sm width and at most the screen minus the margin of the drawer; the body scrolls horizontally only when the content does not fit the screen. The panel keeps its full height and the body scrolls vertically.

<.drawer id="order" placement="right" size="auto" title="Order">
  <.card_table id="items" rows={@items}>...</.card_table>
</.drawer>

width: an integer (px) or a CSS value, through the --lu-panel-w variable of the panel, always limited to the screen. It wins over size. A string with anything but a CSS value (;, {, }, quotes, :) is ignored.

<.drawer id="order" placement="right" width={900} title="Order">...</.drawer>
<.drawer id="order" placement="right" width="min(90vw, 900px)" title="Order">...</.drawer>

Both apply to side drawers (not to placement="bottom", which is as wide as the screen), and to layout="page". sheet/1 takes the same; note that its placement is bottom by default.

<.drawer>

Attr Type Default Values / notes
id (required) :string
open :boolean false
layout :string nil nil, `,page-page: the canvas-v2 sheet (a dim overlay + anasidepanel withheader,.bd,footer), shown only whileopenand closed byon_close(a LiveView event or%JS{}`).
side :string "left" left, right
placement :string nil nil, `,left,right,bottom- The same asside`, which it overrides when given.
size :string nil nil, `,auto,sm,md,lg,wide,xl-auto: the panel takes the width of its content (at least thesm` width, at most the screen minus the margin).
width :any nil A width: an integer (px) or a CSS value ("56rem"), limited to the screen; wins over size. Ignored when not a CSS value.
variant :string nil nil, `,float,flush`
description :string nil
close_button :boolean true
close_label :string "Close"
floating :boolean false A sheet that floats with margins around it, the look of variant="float"; makes a bare drawer a sheet.
overlay :boolean true
lock_scroll :boolean false
prevent_close :boolean false
on_open :any nil
on_close :any nil
target :any nil
class :any nil Merged into the sliding frame.
panel_class :any nil
body_class :any nil
inline :boolean false Static preview: in the page flow, always open, no hook.

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

Slots:

  • <:actions>
  • <:back>
  • <:footer> - attrs: class
  • <:header> - attrs: class, style
  • <:inner_block> (required)
  • <:title> - The sheet's title (the title="..." attribute, a plain string, does the same); draws the header.

<.sheet>

Same as drawer/1 (same attributes and slots), under the name the design vitrine uses.

Attr Type Default Values / notes
id (required) :string
open :boolean false
layout :string nil nil, `,page-page: the canvas-v2 sheet (a dim overlay + anasidepanel withheader,.bd,footer), shown only whileopenand closed byon_close(a LiveView event or%JS{}`).
side :string "left" left, right
placement :string "bottom" nil, `,left,right,bottom- The same asside`, which it overrides when given.
size :string nil nil, `,auto,sm,md,lg,wide,xl-auto: the panel takes the width of its content (at least thesm` width, at most the screen minus the margin).
width :any nil A width: an integer (px) or a CSS value ("56rem"), limited to the screen; wins over size. Ignored when not a CSS value.
variant :string nil nil, `,float,flush`
description :string nil
close_button :boolean true
close_label :string "Close"
floating :boolean false A sheet that floats with margins around it, the look of variant="float"; makes a bare drawer a sheet.
overlay :boolean true
lock_scroll :boolean false
prevent_close :boolean false
on_open :any nil
on_close :any nil
target :any nil
class :any nil Merged into the sliding frame.
panel_class :any nil
body_class :any nil
inline :boolean false Static preview: in the page flow, always open, no hook.

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

Slots:

  • <:actions>
  • <:back>
  • <:footer> - attrs: class
  • <:header> - attrs: class, style
  • <:inner_block> (required)
  • <:title> - The sheet's title (the title="..." attribute, a plain string, does the same); draws the header.

<.sheet_header>

The header of a sheet: title and description (or :content), a back arrow, buttons and the close ×.

Attr Type Default Values / notes
id :string nil The id of the title, for the drawer's aria-labelledby.
drawer :string nil The id of the drawer the close button closes; the closest one when not given.
title :string nil
description :string nil
close_button :boolean true
close_label :string "Close"
class :any nil
style :string nil

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

Slots:

  • <:actions>
  • <:back>
  • <:content>

<.sheet_body>

The scrolling body of a sheet: it takes the height the header and the footer leave.

Attr Type Default Values / notes
class :any nil

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

Slots:

  • <:inner_block> (required)

<.sheet_footer>

The footer of a sheet: the buttons, aligned to the end on a tinted bar.

Attr Type Default Values / notes
class :any nil

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

Slots:

  • <:inner_block> (required)