Skip to content
SevenOne

Search documentation

Search pages and components

Scroll Area

Scrolls its content with a slim custom scrollbar: 10px wide with an 8px thumb that keeps 3:1 contrast.

Installation

npx shadcn@latest add @sevenone/scroll-area

Usage

import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"

Examples

Vertical

Tags

v1.2.0-beta.30
v1.2.0-beta.29
v1.2.0-beta.28
v1.2.0-beta.27
v1.2.0-beta.26
v1.2.0-beta.25
v1.2.0-beta.24
v1.2.0-beta.23
v1.2.0-beta.22
v1.2.0-beta.21
v1.2.0-beta.20
v1.2.0-beta.19
v1.2.0-beta.18
v1.2.0-beta.17
v1.2.0-beta.16
v1.2.0-beta.15
v1.2.0-beta.14
v1.2.0-beta.13
v1.2.0-beta.12
v1.2.0-beta.11
v1.2.0-beta.10
v1.2.0-beta.9
v1.2.0-beta.8
v1.2.0-beta.7
v1.2.0-beta.6
v1.2.0-beta.5
v1.2.0-beta.4
v1.2.0-beta.3
v1.2.0-beta.2
v1.2.0-beta.1
<ScrollArea className="h-72 w-48 rounded-md border" aria-label="Tags">
  <div className="p-4">
    <h4 className="mb-4 text-sm leading-none font-medium">Tags</h4>
    {tags.map((tag) => (
      <React.Fragment key={tag}>
        <div className="text-sm">{tag}</div>
        <Separator className="my-2" />
      </React.Fragment>
    ))}
  </div>
</ScrollArea>

Horizontal

Add a ScrollBar with orientation="horizontal".

Primary #1C1C1C
Info #0749AC
Success #005C27
Warning #6D4700
Destructive #9E141E
Muted text #4C5055
<ScrollArea className="w-96 rounded-md border whitespace-nowrap" aria-label="Brand colors">
  <div className="flex w-max gap-4 p-4">
    {swatches.map((s) => (
      <figure key={s.name} className="shrink-0">
        <div className="h-24 w-32 rounded-md border" style={{ backgroundColor: s.hex }} />
        <figcaption className="pt-2 text-sm text-muted-foreground">
          <span className="font-medium text-foreground">{s.name}</span> {s.hex}
        </figcaption>
      </figure>
    ))}
  </div>
  <ScrollBar orientation="horizontal" />
</ScrollArea>

Accessibility

  • The scrolling area takes keyboard focus, so people can scroll it with the arrow keys; it shows the 2px focus ring.
  • Name it with aria-label or aria-labelledby; it then becomes a named region for screen readers.
  • The thumb uses the input-border color, which is 3:1 on the background, so it stays visible.