> Native Solid 2 fork. Original documentation and designs © WorkOS; historical posts retain their original context.

# Scroll Area

Augments native scroll functionality for custom, cross-browser styling.

## Features

- Scrollbar sits on top of the scrollable content, taking up no space.

- Scrolling is native; no underlying position movements via CSS transformations.

- Shims pointer behaviors only when interacting with the controls, so keyboard controls are unaffected.

- Supports Right to Left direction.

## Anatomy

Import all parts and piece them together.

```jsx
import { ScrollArea } from "@radix-solid/primitives";

export default () => <ScrollArea.Root>

		<ScrollArea.Viewport />

		<ScrollArea.Scrollbar orientation="horizontal">

			<ScrollArea.Thumb />

		</ScrollArea.Scrollbar>

		<ScrollArea.Scrollbar orientation="vertical">

			<ScrollArea.Thumb />

		</ScrollArea.Scrollbar>

		<ScrollArea.Corner />

	</ScrollArea.Root>;
```

## API Reference

### Root

Contains all the parts of a scroll area.

| Prop                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Type      | Default   |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | --------- |
| `asChild`Render through a single-target factory, merging props and behavior with the chosen host. Read our [Composition](../guides/composition) guide for more details.                                                                                                                                                                                                                                                                                                                                                                                                                                 | `boolean` | `false`   |
| `type`Describes the nature of scrollbar visibility, similar to how the scrollbar preferences in MacOS control visibility of native scrollbars. `"auto"` means that scrollbars are visible when content is overflowing on the corresponding orientation. `"always"` means that scrollbars are always visible regardless of whether the content is overflowing. `"scroll"` means that scrollbars are visible when the user is scrolling along its corresponding orientation. `"hover"` when the user is scrolling along its corresponding orientation and when the user is hovering over the scroll area. | `enum`    | `"hover"` |
| `scrollHideDelay`If `type` is set to either `"scroll"` or `"hover"`, this prop determines the length of time, in milliseconds, before the scrollbars are hidden after the user stops interacting with scrollbars.                                                                                                                                                                                                                                                                                                                                                                                       | `number`  | `600`     |
| `dir`The reading direction of the scroll area. If omitted, inherits globally from `DirectionProvider` or assumes LTR (left-to-right) reading mode.                                                                                                                                                                                                                                                                                                                                                                                                                                                      | `enum`    | —         |
| `nonce`An optional nonce attribute that is passed to the inline styles for use in CSP-enabled environments that use strict rules to enhance security.                                                                                                                                                                                                                                                                                                                                                                                                                                                   | `string`  | —         |

### Viewport

The viewport area of the scroll area.

| Prop                                                                                                                                                                    | Type      | Default |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------- |
| `asChild`Render through a single-target factory, merging props and behavior with the chosen host. Read our [Composition](../guides/composition) guide for more details. | `boolean` | `false` |

### Scrollbar

The vertical scrollbar. Add a second `Scrollbar` with an `orientation` prop to enable horizontal scrolling.

| Prop                                                                                                                                                                    | Type      | Default    |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ---------- |
| `asChild`Render through a single-target factory, merging props and behavior with the chosen host. Read our [Composition](../guides/composition) guide for more details. | `boolean` | `false`    |
| `forceMount`Used to force mounting when more control is needed. Useful when controlling animation with Solid-compatible animation libraries.                            | `boolean` | —          |
| `orientation`The orientation of the scrollbar                                                                                                                           | `enum`    | `vertical` |

| Data attribute       | Values                       |
| -------------------- | ---------------------------- |
| `[data-state]`       | `"visible" \| "hidden"`      |
| `[data-orientation]` | `"vertical" \| "horizontal"` |

### Thumb

The thumb to be used in `ScrollArea.Scrollbar`.

| Prop                                                                                                                                                                    | Type      | Default |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------- |
| `asChild`Render through a single-target factory, merging props and behavior with the chosen host. Read our [Composition](../guides/composition) guide for more details. | `boolean` | `false` |

| Data attribute | Values                  |
| -------------- | ----------------------- |
| `[data-state]` | `"visible" \| "hidden"` |

### Corner

The corner where both vertical and horizontal scrollbars meet.

| Prop                                                                                                                                                                    | Type      | Default |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------- |
| `asChild`Render through a single-target factory, merging props and behavior with the chosen host. Read our [Composition](../guides/composition) guide for more details. | `boolean` | `false` |

## Accessibility

In most cases, it's best to rely on native scrolling and work with the customization options available in CSS. When that isn't enough, `ScrollArea` provides additional customizability while maintaining the browser's native scroll behavior (as well as accessibility features, like keyboard scrolling).

### Keyboard Interactions

Scrolling via keyboard is supported by default because the component relies on native scrolling. Specific keyboard interactions may differ between platforms, so we do not specify them here or add specific event listeners to handle scrolling via key events.
