ScrollArea

A scrollable region with slim scrollbars colored by the theme, consistent across browsers.

Status: beta. Category: Layout.

import { ScrollArea } from '@glyphui/ui'

Exports: ScrollArea, scrollAreaStyles.

Notes

  • Give the root a height (or width for horizontal) with className, e.g. h-72.

Example: Vertical list

import { ScrollArea, Separator } from '@glyphui/ui'

const releases = Array.from({ length: 40 }, (_, i) => `v0.${40 - i}.0`)

export default function Example() {
  return (
    <ScrollArea className="h-64 w-56 rounded-md border border-border">
      <div className="p-4">
        <p className="mb-3 text-small font-medium">Releases</p>
        {releases.map((tag) => (
          <div key={tag}>
            <p className="py-1.5 font-mono text-small text-muted-foreground">{tag}</p>
            <Separator />
          </div>
        ))}
      </div>
    </ScrollArea>
  )
}

Example: Horizontal

import { ScrollArea } from '@glyphui/ui'

const swatches = [
  'Glyph',
  'Brutalist',
  'Editorial',
  'Playful',
  'Acme',
  'Nord',
  'Sand',
  'Forest',
  'Ink',
]

export default function Example() {
  return (
    <ScrollArea
      orientation="horizontal"
      className="w-full max-w-lg rounded-md border border-border"
    >
      <div className="flex w-max gap-3 p-4">
        {swatches.map((name) => (
          <div
            key={name}
            className="flex h-24 w-36 shrink-0 items-end rounded-md bg-muted p-3 text-small font-medium"
          >
            {name}
          </div>
        ))}
      </div>
    </ScrollArea>
  )
}

Live page: https://glyphui.xyz/components/scroll-area