ScrollArea

ScrollArea is a cross browser, lightweight and themable alternative to native browser scrollbar.

This panel provides an overview of recent activity associated with your account, including system updates, configuration changes, and important user actions that may require your attention. It is designed to surface relevant information in a compact space without overwhelming the main layout or distracting you from your current task.

As activity accumulates over time, new entries are continuously added to this section while older records remain available for review. Scrolling allows you to explore past events at your own pace, making it easier to understand changes and patterns without navigating away from the current context.

Activity data may include security-related events, billing notifications, feature updates, and changes made by team members across your workspace. Keeping this information in a dedicated scrollable area helps maintain clarity and focus within the interface while still providing access to detailed historical information.

Use this area to monitor recent changes, verify completed actions, and stay informed about updates that may affect your workflow or account status. For a more comprehensive view, additional filters, search options, or detailed logs may be available elsewhere in the application.

basic-demo

Usage#

import { ScrollArea } from '@primereact/ui/scrollarea';
<ScrollArea>
    <ScrollArea.Viewport>
        <ScrollArea.Content />
    </ScrollArea.Viewport>
    <ScrollArea.ThumbX />
    <ScrollArea.ThumbY />
</ScrollArea>

Examples#

Horizontal#

ScrollArea supports horizontal scrolling for content that extends beyond the horizontal viewport.

horizontal-demo
'use client';
import { PhotoService } from '@/shared/services/photo.service';
import { ScrollArea } from '@primereact/ui/scrollarea';
import * as React from 'react';

interface ImageData {
    itemImageSrc: string;
    thumbnailImageSrc: string;
    alt: string;
    title: string;
}

export default function HorizontalDemo() {
    const [images, setImages] = React.useState<ImageData[] | null>(null);

    React.useEffect(() => {
        PhotoService.getImages().then((data) => setImages(data));
    }, []);

    return (
        <div className="flex justify-center">
            <ScrollArea.Root className="border border-surface-200 dark:border-surface-700 rounded-lg max-w-md">
                <ScrollArea.Viewport>
                    <ScrollArea.Content className="flex gap-4 p-4">
                        {images &&
                            images.map((image, index) => (
                                <figure key={index} className="flex-1 min-w-48">
                                    <img src={image.itemImageSrc} alt={image.title} className="object-cover rounded-md" />
                                    <figcaption className="mt-2 text-xs">
                                        <span className="opacity-60">Photo by</span> <span className="font-medium">{image.title}</span>
                                    </figcaption>
                                </figure>
                            ))}
                    </ScrollArea.Content>
                </ScrollArea.Viewport>
                <ScrollArea.ThumbX className="h-2" />
            </ScrollArea.Root>
        </div>
    );
}

Both Scrollbars#

Scrollbar visuals can be styled for a unified look across different platforms.

0
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
both-scrollbars-demo
import { ScrollArea } from '@primereact/ui/scrollarea';

export default function BothScrollbarsDemo() {
    return (
        <div className="flex justify-center">
            <ScrollArea.Root className="h-80 w-80 border border-surface rounded-lg">
                <ScrollArea.Viewport className="p-4">
                    <ScrollArea.Content>
                        <div className="grid grid-cols-[repeat(10,6rem)] grid-rows-[repeat(10,6rem)] gap-4">
                            {Array(100)
                                .fill(null)
                                .map((_, i) => (
                                    <div key={i} className="size-full bg-surface-100 dark:bg-surface-800 rounded-lg flex items-center justify-center">
                                        <span className="text-sm opacity-75">{i}</span>
                                    </div>
                                ))}
                        </div>
                    </ScrollArea.Content>
                </ScrollArea.Viewport>
                <ScrollArea.ThumbY />
                <ScrollArea.ThumbX />
            </ScrollArea.Root>
        </div>
    );
}

Custom#

Scrollbar visuals can be styled for a unified look across different platforms.

This panel provides an overview of recent activity associated with your account, including system updates, configuration changes, and important user actions that may require your attention. It is designed to surface relevant information in a compact space without overwhelming the main layout or distracting you from your current task.

As activity accumulates over time, new entries are continuously added to this section while older records remain available for review. Scrolling allows you to explore past events at your own pace, making it easier to understand changes and patterns without navigating away from the current context.

Activity data may include security-related events, billing notifications, feature updates, and changes made by team members across your workspace. Keeping this information in a dedicated scrollable area helps maintain clarity and focus within the interface while still providing access to detailed historical information.

Use this area to monitor recent changes, verify completed actions, and stay informed about updates that may affect your workflow or account status. For a more comprehensive view, additional filters, search options, or detailed logs may be available elsewhere in the application.

custom-demo
import { ScrollArea } from '@primereact/ui/scrollarea';

export default function BasicDemo() {
    return (
        <div className="flex justify-center">
            <ScrollArea.Root className="max-w-sm h-48">
                <ScrollArea.Viewport>
                    <ScrollArea.Content>
                        <div className="space-y-6 text-sm">
                            <p>
                                This panel provides an overview of recent activity associated with your account, including system updates,
                                configuration changes, and important user actions that may require your attention. It is designed to surface relevant
                                information in a compact space without overwhelming the main layout or distracting you from your current task.
                            </p>

                            <p>
                                As activity accumulates over time, new entries are continuously added to this section while older records remain
                                available for review. Scrolling allows you to explore past events at your own pace, making it easier to understand
                                changes and patterns without navigating away from the current context.
                            </p>

                            <p>
                                Activity data may include security-related events, billing notifications, feature updates, and changes made by team
                                members across your workspace. Keeping this information in a dedicated scrollable area helps maintain clarity and
                                focus within the interface while still providing access to detailed historical information.
                            </p>

                            <p>
                                Use this area to monitor recent changes, verify completed actions, and stay informed about updates that may affect
                                your workflow or account status. For a more comprehensive view, additional filters, search options, or detailed logs
                                may be available elsewhere in the application.
                            </p>
                        </div>
                    </ScrollArea.Content>
                </ScrollArea.Viewport>
                <ScrollArea.ThumbY className="w-1.5 bg-primary" />
            </ScrollArea.Root>
        </div>
    );
}

Accessibility#

Screen Reader#

Scrollbars of the ScrollArea has a scrollbar role along with the aria-controls attribute that refers to the id of the scrollable content container and the aria-orientation to indicate the orientation of scrolling.

Keyboard Support#

KeyFunction
tabMoves focus through the bar.
down arrowScrolls content down when vertical scrolling is available.
up arrowScrolls content up when vertical scrolling is available.
leftScrolls content left when horizontal scrolling is available.
rightScrolls content right when horizontal scrolling is available.