13 · Estrutura e shell

ScrollArea

orientation both/horizontal/vertical · scrollbar always/hover/hidden

Contêiner com rolagem e barra discreta, com sombra indicando mais conteúdo.

Rolando (vertical e horizontal)

PED-2480Cliente 1
PED-2481Cliente 2
PED-2482Cliente 3
PED-2483Cliente 4
PED-2484Cliente 5
PED-2485Cliente 6
PED-2486Cliente 7
PED-2487Cliente 8
PED-2488Cliente 9
PED-2489Cliente 10
PED-2490Cliente 11
PED-2491Cliente 12
PED-2492Cliente 13
PED-2493Cliente 14
Filial 1
Filial 2
Filial 3
Filial 4
Filial 5
Filial 6
Filial 7
Filial 8
.heex
<div class="grid grid-cols-2 gap-4">
  <.scroll_area variant="preview" scrollbar="always" class="h-[200px]">
    <div data-part="scroll-area-content" class="animate-[mo-scroll_8s_ease-in-out_infinite] [--sy:-300px]">
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2480</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 1</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2481</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 2</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2482</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 3</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2483</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 4</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2484</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 5</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2485</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 6</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2486</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 7</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2487</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 8</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2488</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 9</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2489</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 10</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2490</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 11</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2491</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 12</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2492</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 13</span></div>
    <div class="flex h-9 flex-wrap items-center gap-2.5 border-b border-line px-3"><span class="font-mono text-[13px]">PED-2493</span><span class="min-w-0 flex-1 text-[13px] text-muted">Cliente 14</span></div>
    </div>
  </.scroll_area>
  <.scroll_area variant="preview" orientation="horizontal" scrollbar="always" class="h-[110px]">
    <div data-part="scroll-area-content" class="animate-[mo-scrollx_8s_ease-in-out_infinite] [--sx:-420px]">
      <div class="flex w-[900px] gap-2.5 p-3">
      <div class="h-[70px] w-[150px] flex-none rounded-lg border border-line bg-panel p-2.5"><b class="text-[13px]">Filial 1</b></div>
      <div class="h-[70px] w-[150px] flex-none rounded-lg border border-line bg-panel p-2.5"><b class="text-[13px]">Filial 2</b></div>
      <div class="h-[70px] w-[150px] flex-none rounded-lg border border-line bg-panel p-2.5"><b class="text-[13px]">Filial 3</b></div>
      <div class="h-[70px] w-[150px] flex-none rounded-lg border border-line bg-panel p-2.5"><b class="text-[13px]">Filial 4</b></div>
      <div class="h-[70px] w-[150px] flex-none rounded-lg border border-line bg-panel p-2.5"><b class="text-[13px]">Filial 5</b></div>
      <div class="h-[70px] w-[150px] flex-none rounded-lg border border-line bg-panel p-2.5"><b class="text-[13px]">Filial 6</b></div>
      <div class="h-[70px] w-[150px] flex-none rounded-lg border border-line bg-panel p-2.5"><b class="text-[13px]">Filial 7</b></div>
      <div class="h-[70px] w-[150px] flex-none rounded-lg border border-line bg-panel p-2.5"><b class="text-[13px]">Filial 8</b></div>
      </div>
    </div>
  </.scroll_area>
</div>

Uso

<.scroll_area class="h-64">…</.scroll_area>

Regras

  • Barra de 6px em line-strong; sombra de borda só quando há rolagem.

Referência da API

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

A box that scrolls with a thin scrollbar (6px, transparent track). For long menus, lists in a card, the body of a panel. The height comes from class or an inline style.

<.scroll_area style="max-height:16rem">...</.scroll_area>
<.scroll_area focusable label="Release notes" style="max-height:16rem">...</.scroll_area>

stick_bottom keeps a list that grows at its end (a chat) scrolled to its last item, unless the reader scrolled up: it mounts the LedgerUI.ScrollBottom hook (needs a stable id).

variant

  • "plain" (default): the bare scrolling box.
  • "panel": the canvas card that scrolls: border, background and radius of a panel.
  • "preview": the canvas picture of a scroll area: a frame that clips the content and draws the scrollbar thumb (vertical or horizontal, animated) according to orientation; scrollbar hover fades the thumb out and hidden takes it away. The content is whatever the slot holds (the canvas wraps it in an animated animate-[mo-scroll_…] / animate-[mo-scrollx_…]). For the documentation and the showcase only.

<.scroll_area>

Attr Type Default Values / notes
variant :string "plain" plain, panel, preview
orientation :string "vertical" both, horizontal, vertical
scrollbar :string "hover" always, hidden, hover
focusable :boolean false
label :string nil
id :string nil
stick_bottom :boolean false
class :any nil

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

Slots:

  • <:inner_block> (required)