Components
Scroll Area
A styled scroll container with always-available scrollbars.
Installation
$ npx veil-ui@latest add scroll-areaUsage
import { ScrollArea } from "@/components/ui/scroll-area";
<ScrollArea className="h-64 rounded-md border">
<div className="p-4">Scrollable content</div>
</ScrollArea>;Examples
Vertical
Horizontal
Both axes
API reference
ScrollArea wraps the Radix root and viewport. Give it a height or width so
there is something to scroll.
| Prop | Type | Default | Description |
|---|---|---|---|
| type | "auto" | "always" | "scroll" | "hover" | "hover" | When the scrollbar becomes visible. |
| ...props | React.ComponentProps<typeof ScrollAreaPrimitive.Root> | — | All Radix scroll area root props. |
Subcomponents
ScrollBar— scrollbar with its thumb; passorientation="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>