Drawer
placement left · right · bottom · variant float/flush · size sm–xl · fixed footer
A side panel for details and editing without leaving the list.
Entering from the side and from below
<div class="grid grid-cols-3 gap-3"> <div :for={{p, label, anim} <- [{"right", "placement=right · float", "animate-[lu-dr_4s_cubic-bezier(.2,.8,.2,1)_infinite]"}, {"left", "left", "animate-[lu-drl_4s_cubic-bezier(.2,.8,.2,1)_infinite]"}, {"bottom", "bottom", "animate-[lu-drb_4s_cubic-bezier(.2,.8,.2,1)_infinite]"}]} class="relative overflow-hidden rounded-[14px] bg-page shadow-[inset_0_0_0_1px_var(--lu-line)] h-[220px] [&>[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> <.drawer inline id={"dr-#{p}"} placement={p} title="Pedido #2491" close_button={false} class={[anim, "w-[46%]!"]}> <.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> </.drawer> <span class="absolute bottom-2 left-2.5 z-50 font-mono text-[11px] text-muted">{label}</span> </div> </div>
variant float × flush
<div class="grid grid-cols-2 gap-3"> <div :for={{v, label} <- [{"float", "float (12px das bordas)"}, {"flush", "flush (colado)"}]} class="relative overflow-hidden rounded-[14px] bg-page shadow-[inset_0_0_0_1px_var(--lu-line)] h-[200px] [&>[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> <.drawer inline id={"dr-var-#{v}"} placement="right" variant={v} title="Pedido #2491" close_button={false} class="w-[46%]!"> <.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> </.drawer> <span class="absolute bottom-2 left-2.5 z-50 font-mono text-[11px] text-muted">{label}</span> </div> </div>
size (width)
<div class="flex flex-col gap-2"> <div :for={{s, w, px} <- [{"sm", "w-[200px]", "400px"}, {"md", "w-[260px]", "520px"}, {"lg", "w-[320px]", "640px"}, {"wide", "w-[400px]", "800px"}, {"xl", "w-[540px]", "1080px"}]} class="flex flex-wrap items-center gap-2.5"> <span class="w-11 font-mono text-xs text-muted">{s}</span> <div class={["flex h-[22px] items-center rounded-md bg-sunken px-2 font-mono text-xs text-muted shadow-[inset_0_0_0_1px_var(--lu-line)]", w]}>{px}</div> </div> </div>
Try it: opens the real drawer (placement, variant, size)
<div class="flex flex-col gap-3"> <div class="flex flex-wrap items-center gap-2.5"> <span class="w-20 font-mono text-xs text-muted">placement</span> <.button :for={{id, label} <- [{"dr-live-right", "Direita"}, {"dr-live-left", "Esquerda"}, {"dr-live-flush", "Colada (flush)"}, {"dr-live-bottom", "Por baixo"}]} color="neutral" variant="outline" size="sm" aria-haspopup="dialog" aria-controls={id} phx-click={LedgerUI.open(id)}>{label}</.button> </div> <div class="flex flex-wrap items-center gap-2.5"> <span class="w-20 font-mono text-xs text-muted">size</span> <.button :for={s <- ~w(sm md lg wide xl)} color="neutral" variant="soft" size="sm" aria-haspopup="dialog" aria-controls={"dr-live-s-#{s}"} phx-click={LedgerUI.open("dr-live-s-#{s}")}>{s}</.button> </div> <.drawer id="dr-live-right" placement="right" title="Novo cliente" description="Quem compra de você."> <p class="m-0 text-[14px] text-muted">Painel à direita, solto das bordas. Feche pelo ×, pelo Esc ou clicando no fundo.</p> <:footer> <.button color="neutral" variant="soft" size="sm" phx-click={LedgerUI.close("dr-live-right")}>Cancelar</.button> <.button color="neutral" size="sm" phx-click={LedgerUI.close("dr-live-right")}>Salvar</.button> </:footer> </.drawer> <.drawer id="dr-live-left" placement="left" title="Filtros" description="Refine a lista."> <p class="m-0 text-[14px] text-muted">Painel à esquerda.</p> <:footer> <.button color="neutral" variant="soft" size="sm" phx-click={LedgerUI.close("dr-live-left")}>Fechar</.button> </:footer> </.drawer> <.drawer id="dr-live-flush" placement="right" variant="flush" title="Pedido #2491" description="variant=flush"> <p class="m-0 text-[14px] text-muted">Colado na borda da janela.</p> <:footer> <.button color="neutral" variant="soft" size="sm" phx-click={LedgerUI.close("dr-live-flush")}>Fechar</.button> </:footer> </.drawer> <.drawer id="dr-live-bottom" placement="bottom" title="Ações do pedido" description="placement=bottom"> <p class="m-0 text-[14px] text-muted">A folha de baixo do celular.</p> <:footer> <.button color="neutral" variant="soft" size="sm" phx-click={LedgerUI.close("dr-live-bottom")}>Fechar</.button> </:footer> </.drawer> <.drawer :for={{s, px} <- [{"sm", "400px"}, {"md", "520px"}, {"lg", "640px"}, {"wide", "800px"}, {"xl", "1080px"}]} id={"dr-live-s-#{s}"} placement="right" size={s} title="Pedido #2491" description={"size=#{s} · #{px}"}> <p class="m-0 text-[14px] text-muted">Largura do painel: {px}.</p> <:footer> <.button color="neutral" variant="soft" size="sm" phx-click={LedgerUI.close("dr-live-s-#{s}")}>Fechar</.button> </:footer> </.drawer> </div>
Try it: size="auto" and width (the content's width or yours)
<% 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-col gap-3">
<div class="flex flex-wrap items-center gap-2.5">
<span class="w-20 font-mono text-xs text-muted">size</span>
<.button color="neutral" variant="outline" size="sm" aria-haspopup="dialog" aria-controls="dr-auto" phx-click={LedgerUI.open("dr-auto")}>size="auto"</.button>
<span class="text-xs text-muted">A largura do conteúdo (mínimo 400 px, no máximo a tela).</span>
</div>
<div class="flex flex-wrap items-center gap-2.5">
<span class="w-20 font-mono text-xs text-muted">width</span>
<.button color="neutral" variant="soft" size="sm" aria-haspopup="dialog" aria-controls="dr-w-px" phx-click={LedgerUI.open("dr-w-px")}>{"width={720}"}</.button>
<.button color="neutral" variant="soft" size="sm" aria-haspopup="dialog" aria-controls="dr-w-css" phx-click={LedgerUI.open("dr-w-css")}>width="min(90vw, 560px)"</.button>
<.button color="neutral" variant="soft" size="sm" aria-haspopup="dialog" aria-controls="dr-w-left" phx-click={LedgerUI.open("dr-w-left")}>placement="left" · width="30rem"</.button>
</div>
<.drawer id="dr-auto" placement="right" size="auto" title="Itens do pedido" description='size="auto"'>
<.table id="dr-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("dr-auto")}>Fechar</.button>
</:footer>
</.drawer>
<.drawer id="dr-w-px" placement="right" width={720} title="Pedido #2491" description="width={720}">
<p class="m-0 text-[14px] text-muted">Largura de 720 px, sempre limitada à tela.</p>
<:footer>
<.button color="neutral" variant="soft" size="sm" phx-click={LedgerUI.close("dr-w-px")}>Fechar</.button>
</:footer>
</.drawer>
<.drawer id="dr-w-css" placement="right" width="min(90vw, 560px)" title="Pedido #2491" description='width="min(90vw, 560px)"'>
<p class="m-0 text-[14px] text-muted">Qualquer valor CSS de largura; vale mais que o <code class="font-mono text-xs">size</code>.</p>
<:footer>
<.button color="neutral" variant="soft" size="sm" phx-click={LedgerUI.close("dr-w-css")}>Fechar</.button>
</:footer>
</.drawer>
<.drawer id="dr-w-left" placement="left" width="30rem" title="Filtros" description='width="30rem"'>
<p class="m-0 text-[14px] text-muted">Também vale nos drawers da esquerda.</p>
<:footer>
<.button color="neutral" variant="soft" size="sm" phx-click={LedgerUI.close("dr-w-left")}>Fechar</.button>
</:footer>
</.drawer>
</div>
Usage
<.drawer id="account" placement="right" floating>…</.drawer>
Rules
- Floating by default, 8px from the edges;
edgesticks it to the side. - Width 380–480; a fixed footer with actions.
API reference
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 (thetitle="..."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 (thetitle="..."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)