Scroll Area
A scroll container with custom overlay scrollbars. Scrolling stays native (the viewport is a real overflow container); the scrollbars are painted from the scroll metrics.
Import
Section titled “Import”<script> import ScrollArea from "@invisible-ui/svelte/ScrollArea.svelte";</script><script setup> import { ScrollArea } from "@invisible-ui/vue";</script>import { ScrollArea } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-scroll-area></ds-scroll-area>In Elements, the children become the scrolling content:
<ds-scroll-area max-height="10rem" label="Terms"> <p>…</p></ds-scroll-area>| Prop | Type | Default | Description |
|---|---|---|---|
orientation | ScrollOrientation | "vertical" | Scrollable axes. |
maxHeight | string | "12rem" | Max height of the viewport. |
label | string | undefined | undefined | Accessible name for the region. |
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | ScrollOrientation | "vertical" | Which axes scroll. Defaults to vertical. |
maxHeight | string | "12rem" | Max size of the viewport (the scroll constraint), e.g. "12rem". |
label | string | undefined | Optional accessible name; makes the viewport a labelled scroll region. |
Slots: default.
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | ScrollOrientation | "vertical" | Which axes scroll. Defaults to vertical. |
maxHeight | string | "12rem" | Largest block size of the viewport, the scroll constraint, such as "12rem". |
label | string | — | Optional accessible name; makes the viewport a labelled region. Two scroll areas on a page should not share one: the landmark list would show the same entry twice. |
children | ReactNode | — | The scrolling content. |
| Attribute | Reactive | Description |
|---|---|---|
orientation | yes | vertical|horizontal|both |
max-height | yes | the viewport's maximum block size; "12rem" by default |
label | yes | makes the viewport a labelled region; give each scroll area on a page its own name |
Reactive attributes re-render the element when they change after the first render.
The scrollable content is the default slot.
Accessibility
Section titled “Accessibility”- Native scrolling (keyboard works); custom scrollbars are decorative.
- In right-to-left text the horizontal thumb starts at the right, follows the scroll position and drags the content the way it moves.
- With a
labelthe viewport becomes a landmark, so it appears in the landmark list: give each scroll area on a page its own name. Without alabelit is a plain scroller and claims no place in that list.
Example
Section titled “Example”<ScrollArea maxHeight="10rem" label="Terms"><p>…</p></ScrollArea>In React, useScrollArea gives the same geometry and thumb drag to markup
of your own:
<ScrollArea maxHeight="10rem" label="Terms"> <p>…</p></ScrollArea>Themeable via --ds-scroll-area-*.