v0.0.2
Demos (demo panel, opens in a new tab)

Scroll area

Scrolls long or wide content inside a bounded box, with a thin scrollbar.

zb:scroll-area zubazar/ui · free (MIT)

Vertical scrolling

Vertical scrolling: view
BLADE

When the content goes past max-height, only the inside of the area scrolls and the page stays in place.

blade
<zb:scroll-area max-height="15rem" label="Recently sold products" class="rounded-sm border border-line">
    <ul class="divide-y divide-line-soft">
        @foreach (['Wireless headphones', 'Mechanical keyboard', 'USB-C charger', '27-inch monitor', 'Ergonomic chair', 'Laptop stand', 'Webcam', 'External SSD 1 TB', 'Bluetooth speaker', 'Smartwatch'] as $product)
            <li class="flex items-center justify-between gap-4 px-4 py-2.5 text-sm">
                <span class="text-ink">{{ $product }}</span>
                <span class="text-xs text-muted">September {{ 20 - $loop->index }}</span>
            </li>
        @endforeach
    </ul>
</zb:scroll-area>
PropValues
max-heightCSS length or number of pixels
heightFixed height, in the same format
labelScreen reader name (role="region")

Horizontal scrolling

Horizontal scrolling: view
BLADE

direction="horizontal" scrolls the content sideways, and both scrolls in both directions.

blade
<zb:scroll-area direction="horizontal" label="Category summaries">
    <div class="flex w-max gap-3 pb-3">
        @foreach (['Electronics' => 42, 'Apparel' => 18, 'Home & living' => 35, 'Beauty' => 27, 'Sports' => 22, 'Books' => 31, 'Toys' => 56] as $category => $orders)
            <div class="w-48 rounded-sm border border-line p-4">
                <p class="text-xs text-muted">{{ $category }}</p>
                <p class="mt-1 text-xl font-semibold text-ink">{{ $orders }} orders</p>
            </div>
        @endforeach
    </div>
</zb:scroll-area>
PropValues
directionvertical | horizontal | both

Edge shadows

Edge shadows: view
BLADE

With shadows, edges with hidden content behind them fade out and turn sharp again at the start or the end.

blade
<zb:scroll-area max-height="12rem" shadows label="Customer notes" class="text-sm">
    <div class="space-y-3 pe-3">
        <p>The customer was called; the return request was approved and the return shipping code was emailed.</p>
        <p>The billing address was changed to the company address. The accounting team was recorded as the contact person in case of need.</p>
        <p>A discount was requested for a bulk purchase. The request was passed on to the sales team; a reply is pending.</p>
        <p>The next order will be gift-wrapped; the note should appear on the warehouse team's screen.</p>
        <p>Because the customer is not at the address on weekdays, deliveries should be rescheduled for Saturdays.</p>
    </div>
</zb:scroll-area>

<zb:scroll-area direction="horizontal" shadows label="Category filters" class="self-start">
    <div class="flex w-max gap-2 py-1">
        @foreach (['All', 'Electronics', 'Home & living', 'Apparel & accessories', 'Beauty', 'Sports & outdoors', 'Books & stationery'] as $category)
            <zb:badge :variant="$loop->first ? 'primary' : 'secondary'">{{ $category }}</zb:badge>
        @endforeach
    </div>
</zb:scroll-area>
PropValues
shadowstrue | false

Inside a card and a drawer

Inside a card and a drawer: view
BLADE

Pass :padding="false" in a card, or body-class="flex min-h-0 flex-1 flex-col" in a drawer and min-h-0 flex-1 on the area; only the content in between scrolls.

blade
<zb:card title="Notifications" :padding="false" class="max-w-sm">
    <zb:scroll-area max-height="13rem" shadows label="Notifications">
        <ul class="divide-y divide-line-soft text-sm">
            @foreach (['Order #10482 delivered.', '3 new reviews added to Wireless headphones.', 'Order #10475 shipment delayed.', 'Support ticket assigned to a new agent.', 'September sales report is ready.', 'Kadıköy warehouse stock list updated.', 'Monthly invoice summary sent.'] as $notification)
                <li class="px-5 py-3">{{ $notification }}</li>
            @endforeach
        </ul>
    </zb:scroll-area>
    <zb:slot:footer>
        <zb:drawer.trigger name="scroll-area-history"><zb:button variant="white" size="sm">Open full history</zb:button></zb:drawer.trigger>
    </zb:slot:footer>
</zb:card>

<zb:drawer name="scroll-area-history" title="Order history" body-class="flex min-h-0 flex-1 flex-col">
    <zb:scroll-area shadows label="Order history" class="min-h-0 flex-1 p-5">
        <ol class="space-y-4 text-sm">
            @foreach (range(1, 18) as $day)
                <li>
                    <p class="font-medium text-ink">September {{ 19 - $day }}, 2026</p>
                    <p class="text-muted">Kadıköy warehouse · {{ 4 + $day % 5 }} orders shipped</p>
                </li>
            @endforeach
        </ol>
    </zb:scroll-area>
    <zb:slot:footer>
        <zb:drawer.close><zb:button variant="white">Close</zb:button></zb:drawer.close>
    </zb:slot:footer>
</zb:drawer>

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
direction—verticalvertical · horizontal · both: the direction to scroll in
max-height—nullMaximum height: a CSS length (16rem, 50vh) or a number of pixels; a max-h-* class can be passed instead
height—nullFixed height, in the same format as max-height; an h-* class can be passed instead
shadowsbooleanfalseFades the edges that have hidden content behind them (no Alpine needed)
label—nullScreen reader name; when given, the area becomes role="region"

Slots: default content (the scrolled content). The area gets tabindex="0" by default; class, style, and other attributes are added to the container.

Developer notes

Events, hooks and details
  • No separate JavaScript library is needed; the scrollbar adapts to light and dark mode.
  • The area takes focus with Tab and scrolls with the arrow keys and Page Up / Page Down; when label is given, screen readers announce it as a region with that name.
  • In horizontal scrolling the parent container sets the area's width; wrap the row with w-max so the content keeps its own width. It scrolls with a finger on touch screens and with Shift + wheel on a mouse.
  • The edge fade is a CSS mask, so it doesn't depend on the background color. Zubazar UI's JavaScript tracks the scroll position (no Alpine needed) and measures again when the content grows or shrinks or Livewire adds rows.
  • In a card, :padding="false" extends the area to the card's edge; in a drawer, body-class turns off the body's own scrolling, so the header and the footer stay in place.
Zubazar UI · ZubazarDesigned for people.