Veil UI
Components

Scroll Area

A styled scroll container with always-available scrollbars.

Installation

$ npx veil-ui@latest add scroll-area

Usage

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

<ScrollArea className="h-64 rounded-md border">
  <div className="p-4">Scrollable content</div>
</ScrollArea>;

Examples

Vertical

Row 1
Row 2
Row 3
Row 4
Row 5
Row 6
Row 7
Row 8
Row 9
Row 10
Row 11
Row 12
Row 13
Row 14
Row 15
Row 16
Row 17
Row 18
Row 19
Row 20

Horizontal

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

Both axes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

API reference

ScrollArea wraps the Radix root and viewport. Give it a height or width so there is something to scroll.

PropTypeDefaultDescription
type"auto" | "always" | "scroll" | "hover""hover"When the scrollbar becomes visible.
...propsReact.ComponentProps<typeof ScrollAreaPrimitive.Root>—All Radix scroll area root props.

Subcomponents

  • ScrollBar — scrollbar with its thumb; pass orientation="horizontal" for horizontal scrollers.

Accessibility

  • The viewport is keyboard scrollable and shows a visible focus ring.
  • Scrollbars are pointer affordances; content remains reachable with the keyboard and screen readers.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add scroll-area --framework vue or switch the framework in components.json.

<script setup lang="ts">
import {
  ScrollAreaCorner,
  ScrollAreaRoot,
  ScrollAreaViewport,
} from "reka-ui";

import { cn } from "@/lib/utils";

import ScrollBar from "./ScrollBar.vue";

const props = withDefaults(
  defineProps<{
    class?: string;
    type?: "auto" | "always" | "scroll" | "hover";
  }>(),
  { type: "hover" },
);
</script>

<template>
  <ScrollAreaRoot
    data-slot="scroll-area"
    :type="type"
    :class="cn('relative overflow-hidden', props.class)"
  >
    <ScrollAreaViewport
      data-slot="scroll-area-viewport"
      class="size-full rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:ring-ring/50"
    >
      <slot />
    </ScrollAreaViewport>
    <ScrollBar />
    <ScrollAreaCorner />
  </ScrollAreaRoot>
</template>

On this page