---
title: Scroll Area
description: Scrollable content area with styled scrollbar
visibility: guest
draft: false
---

# Scroll Area

A themed scrollable container that matches your WireKit design tokens. Wraps the built-in `.wk-scrollbar` CSS utility into a component with configurable orientation, max-height, and keyboard accessibility.

## Basic Usage

:::preview{title="Vertical scroll area"}
<x-wirekit::scroll-area style="height: 12rem; border-radius: 0.5rem; border: 1px solid var(--color-wk-border); padding: 0.75rem;">
    <p style="margin-bottom: 0.75rem;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
    <p style="margin-bottom: 0.75rem;">Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p style="margin-bottom: 0.75rem;">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p>
    <p style="margin-bottom: 0.75rem;">Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</p>
    <p style="margin-bottom: 0.75rem;">Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.</p>
    <p style="margin-bottom: 0.75rem;">Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur. Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur.</p>
    <p style="margin-bottom: 0.75rem;">At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident.</p>
    <p style="margin-bottom: 0.75rem;">Similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit.</p>
    <p style="margin-bottom: 0.75rem;">Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus.</p>
    <p>Ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. Hanc ego cum teneam sententiam, quid est cur verear ne ad eam non possim accommodare?</p>
</x-wirekit::scroll-area>
:::

## Orientation

### Horizontal

`orientation="horizontal"` scrolls the x-axis. Give the content an intrinsic
width wider than the area (here a `width: max-content` row of fixed-width tiles)
and it overflows sideways.

:::preview{title="Horizontal scroll area"}
<x-wirekit::scroll-area orientation="horizontal" style="width: 28rem; max-width: 100%; height: 8rem; border-radius: 0.5rem; border: 1px solid var(--color-wk-border); padding: 0.75rem;">
    <x-wirekit::row gap="md" style="width: max-content;">
        <div style="height: 6rem; width: 12rem; flex-shrink: 0; border-radius: var(--radius-wk-lg); background: var(--color-wk-bg-muted);"></div>
        <div style="height: 6rem; width: 12rem; flex-shrink: 0; border-radius: var(--radius-wk-lg); background: var(--color-wk-bg-muted);"></div>
        <div style="height: 6rem; width: 12rem; flex-shrink: 0; border-radius: var(--radius-wk-lg); background: var(--color-wk-bg-muted);"></div>
        <div style="height: 6rem; width: 12rem; flex-shrink: 0; border-radius: var(--radius-wk-lg); background: var(--color-wk-bg-muted);"></div>
    </x-wirekit::row>
</x-wirekit::scroll-area>
:::

### Both Directions

`orientation="both"` scrolls on both axes at once — for content that is wider
AND taller than the area (a large canvas, a wide table, a diagram).

:::preview{title="Scroll on both axes"}
<x-wirekit::scroll-area orientation="both" style="width: 28rem; max-width: 100%; height: 12rem; border-radius: 0.5rem; border: 1px solid var(--color-wk-border); padding: 0.75rem;">
    <div style="width: 40rem; height: 20rem; border-radius: var(--radius-wk-lg); background: var(--color-wk-bg-muted);"></div>
</x-wirekit::scroll-area>
:::

## Edge Fade

`fade` dissolves the content at the overflow edge, hinting there is more to
scroll. It masks the **content itself** (`mask-image`) rather than laying a
colored gradient on top — so it adapts to any background automatically, with
nothing to keep in sync with the surface color.

The fade follows the scroll axis: top/bottom for `vertical` (and `both`),
left/right for `horizontal`.

**`start` and `end` mean the reading start and end, not the left and right.** In a
right-to-left document — `dir="rtl"` anywhere above the component — a horizontal
`fade="start"` sits on the right edge and `fade="end"` on the left, which is where
those edges are for a reader of Arabic or Hebrew. Nothing to configure: the
component reads the document direction.

Worth knowing if you write CSS around it: there is no logical keyword for a
gradient, so this is a `[dir="rtl"]` override in the stylesheet rather than
something `mask-image` does on its own. `fade="both"` is symmetric and behaves
identically in either direction.

:::preview{title="Fade on both edges"}
<x-wirekit::scroll-area fade="both" style="height: 10rem; border-radius: 0.5rem; border: 1px solid var(--color-wk-border); padding: 0.75rem;">
    <p style="margin-bottom: 0.75rem;">Scroll me — the top and bottom edges dissolve into the background, so it is obvious there is more content in both directions.</p>
    <p style="margin-bottom: 0.75rem;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    <p style="margin-bottom: 0.75rem;">Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
    <p style="margin-bottom: 0.75rem;">Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit.</p>
</x-wirekit::scroll-area>
:::

Use a single edge when only one direction can overflow — a log that grows
downward, for example, only needs the bottom (`end`) faded.

:::preview{title="Fade the end edge only"}
<x-wirekit::scroll-area fade="end" style="height: 10rem; border-radius: 0.5rem; border: 1px solid var(--color-wk-border); padding: 0.75rem;">
    <p style="margin-bottom: 0.75rem;">The first line stays crisp — only the bottom edge fades.</p>
    <p style="margin-bottom: 0.75rem;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    <p style="margin-bottom: 0.75rem;">Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
    <p style="margin-bottom: 0.75rem;">Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit.</p>
</x-wirekit::scroll-area>
:::

### `fade="auto"` — only where there really is more

A named edge is unconditional CSS, and that is its limit as well as its virtue.
It fades the top edge while you are already at the top, the bottom edge while
you are at the bottom, and both edges on a scroll area whose content fits and
cannot scroll at all — taking ink off text that is entirely visible, to signal
something that is not true.

`fade="auto"` measures instead. The mask appears only on an edge the content
actually continues past: the bottom edge at the top of the area, the top edge at
the bottom, both in between, and nothing while everything fits.

:::preview{title="Fade only where content continues"}
<x-wirekit::scroll-area fade="auto" style="height: 10rem; border-radius: 0.5rem; border: 1px solid var(--color-wk-border); padding: 0.75rem;">
    <p style="margin-bottom: 0.75rem;">Start scrolling and the top edge picks up its fade; reach the bottom and it lets go of the other one.</p>
    <p style="margin-bottom: 0.75rem;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    <p style="margin-bottom: 0.75rem;">Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
    <p style="margin-bottom: 0.75rem;">Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit.</p>
</x-wirekit::scroll-area>
:::

It follows content that arrives later, which is the case worth having it for — a
transcript that appends a message, a list a search filters down, a panel that
opens. Nothing to call and nothing to refresh.

::: warning It needs JavaScript, and it fails toward no mask
`auto` is the one value that does. Where scripts do not run, the area renders
with **no fade at all** and scrolls exactly as it would have — a missing hint
rather than dissolved text. Choose a named edge when you want the fade to be
guaranteed and can accept it being occasionally wrong; choose `auto` when you
would rather have nothing than the wrong hint.
:::

Tune the depth with the `--fade-wk-size` token — globally in `:root` or per
instance:

```blade
{{-- 1. A deeper, softer fade on this one scroll area --}}
<x-wirekit::scroll-area fade="both" style="--fade-wk-size: 4rem;">
    {{-- content --}}
</x-wirekit::scroll-area>
```

## Max Height

Use the `maxHeight` prop for scroll areas with dynamic content:

```blade
<x-wirekit::scroll-area max-height="200px">
    {{-- Long list of items --}}
    @foreach($items as $item)
        <div>{{ $item->name }}</div>
    @endforeach
</x-wirekit::scroll-area>
```

Or use Tailwind classes directly:

```blade
<x-wirekit::scroll-area class="max-h-64">
    {{-- Content --}}
</x-wirekit::scroll-area>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `orientation` | string | `'vertical'` | Scroll direction: `'vertical'`, `'horizontal'`, `'both'` |
| `maxHeight` | string\|null | `null` | CSS max-height value (e.g. `'200px'`, `'50vh'`) |
| `fade` | bool\|string | `false` | Edge fade along the scroll axis: `false` / `'none'`, `'both'`, `'start'`, `'end'`, `'auto'` (measured — see [above](#fadeauto--only-where-there-really-is-more)) |
| `scope` | string\|null | `null` | Scoped personalization key |

## Accessibility

- Container has `tabindex="0"` — keyboard users can focus the scroll area and scroll with arrow keys
- Container has `role="region"` with `aria-label="Scrollable content"` — screen readers announce it as a navigable region
- Keyboard scrolling works via native browser behavior once the container is focused
- **The edge fade never hides focus.** When anything inside the area is focused
  (`:focus-within`), the mask is dropped entirely — so a keyboard-focused child
  at an edge can never be faded out from under the user (WCAG 2.4.7 Focus
  Visible). The fade is static, so there is no motion to reduce.

## Keyboard Interaction

This component is a layout wrapper. Keyboard interaction is delegated to its children.

## Design Tokens

The scroll area inherits scrollbar styles from the `.wk-scrollbar` CSS utility, which uses these tokens:

| Element | Token |
| --- | --- |
| Scrollbar track | `--color-wk-bg-muted` |
| Scrollbar thumb | `--color-wk-text-subtle` |
| Scrollbar thumb hover | `--color-wk-text-muted` |
| Font family | `--font-wk-sans` |
| Edge-fade depth (`fade`) | `--fade-wk-size` (default `2rem`) |

## Customization

Override defaults in `config/wirekit.php`:

```php
'components' => [
    // 1. Turn the edge fade on for every scroll area by default
    'scroll-area' => ['fade' => 'both'],
],
```

## Further Reading

- [WCAG 2.1.1: Keyboard](https://www.w3.org/WAI/WCAG21/Understanding/keyboard.html) — scrollable regions must be keyboard-accessible
- [MDN: `overflow`](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow)
- [MDN: CSS Scrollbar Styling](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_scrollbars_styling)
