A scroll container with a thin, token-coloured scrollbar.

Last updated

Release note 1

Release note 2

Release note 3

Release note 4

Release note 5

Release note 6

Release note 7

Release note 8

Release note 9

Release note 10

Release note 11

Release note 12

Release note 13

Release note 14

Release note 15

Release note 16

Release note 17

Release note 18

Release note 19

Release note 20

Show code
<ScrollArea height="10rem" aria-label="Changelog">
…
</ScrollArea>

Add

npx @ava-ui/apogee add scroll-area

No Apogee dependencies.

Usage

---
import ScrollArea from '@/components/apogee/ScrollArea/ScrollArea.astro'

<JsNote fallback="The box scrolls normally, stays in the Tab order and shows no fade.">
  Keeps the box in the Tab order only while its content overflows. With `fade`, sets `data-fade` on the box as it scrolls so the hidden edge fades.
</JsNote>
---
<ScrollArea height="20rem" aria-label="Members">
  <ul>…</ul>
</ScrollArea>

API

@composable. Any other native attribute passes through.

Prop Type Default Description
direction 'vertical' | 'horizontal' | 'both' 'vertical' Which axes scroll.
height string — Max height, any CSS length.
maxHeight string — Alias of height.
fade boolean false Fade the edge that hides content (a small island).
scrollbar 'thin' | 'hidden' | 'hover' 'thin' Scrollbar treatment.
class string — Extra classes, merged last.

Variants

Row 1

Row 2

Row 3

Row 4

Row 5

Row 6

Row 7

Row 8

Row 9

Row 10

Row 11

Row 12

Item 1Item 2Item 3Item 4Item 5Item 6Item 7Item 8Item 9Item 10Item 11Item 12

A long row 1 that overflows horizontally as well

A long row 2 that overflows horizontally as well

A long row 3 that overflows horizontally as well

A long row 4 that overflows horizontally as well

A long row 5 that overflows horizontally as well

A long row 6 that overflows horizontally as well

A long row 7 that overflows horizontally as well

A long row 8 that overflows horizontally as well

A long row 9 that overflows horizontally as well

A long row 10 that overflows horizontally as well

A long row 11 that overflows horizontally as well

A long row 12 that overflows horizontally as well

Show code
<ScrollArea direction="vertical" height="8rem">…</ScrollArea>
<ScrollArea direction="horizontal">…</ScrollArea>
<ScrollArea direction="both" height="8rem">…</ScrollArea>

Fade and scrollbar

Every scrollbar value, and fade:

Line 1

Line 2

Line 3

Line 4

Line 5

Line 6

Line 7

Line 8

Line 9

Line 10

Line 11

Line 12

Line 13

Line 14

scrollbar="thin"

Line 1

Line 2

Line 3

Line 4

Line 5

Line 6

Line 7

Line 8

Line 9

Line 10

scrollbar="hidden"

Line 1

Line 2

Line 3

Line 4

Line 5

Line 6

Line 7

Line 8

Line 9

Line 10

scrollbar="hover"

Line 1

Line 2

Line 3

Line 4

Line 5

Line 6

Line 7

Line 8

Line 9

Line 10

Show code
<ScrollArea maxHeight="8rem" fade>…</ScrollArea>
<ScrollArea maxHeight="8rem" scrollbar="thin">…</ScrollArea>
<ScrollArea maxHeight="8rem" scrollbar="hidden">…</ScrollArea>
<ScrollArea maxHeight="8rem" scrollbar="hover">…</ScrollArea>

fade with direction="both" fades the top and bottom edges only.

Short content

When nothing overflows, the box leaves the Tab order (there is nothing to scroll); it rejoins as soon as its content grows past the height.

Line 1

Line 2

Show code
<ScrollArea maxHeight="8rem" aria-label="Two lines">…</ScrollArea>

Accessibility

  • While its content overflows, the container has tabindex="0" so keyboard users can focus it and scroll with the arrow keys; it shows the focus ring. When nothing overflows it leaves the Tab order.
  • Give it an aria-label (or aria-labelledby) when nothing nearby names the region.

Tokens

Token Used for
--border-neutral Scrollbar thumb
--outline-color-focus Focus outline

Layout primitive, so no content rules.