ScrollPanel is a cross browser, lightweight and skinnable alternative to native browser scrollbar.
import { ScrollPanel } from 'primereact/scrollpanel';
ScrollPanel is defined using dimensions for the scrollable viewport.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.
<ScrollPanel style={{ width: '100%', height: '150px' }}>
<p>
Lorem ipsum dolor ...
</p>
</ScrollPanel>
Scrollbar visuals can be styled for a unified look across different platforms.
<ScrollPanel style={{ width: '100%', height: '200px' }} className="custombar1">
<p>
Lorem ipsum dolor ...
</p>
</ScrollPanel>
<ScrollPanel style={{ width: '100%', height: '200px' }} className="custombar2">
<p>
Lorem ipsum dolor ...
</p>
</ScrollPanel>
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-scrollpanel | Container element. |
p-scrollpanel-wrapper | Wrapper of content section. |
p-scrollpanel-content | Content section. |
p-scrollpanel-bar | Scrollbar handle. |
p-scrollpanel-bar-x | Scrollbar handle of a horizontal bar. |
p-scrollpanel-bar-y | Scrollbar handle of a vertical bar |
Scrollbars of the ScrollPanel 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.
Key | Function |
---|---|
down arrow | Scrolls content down when vertical scrolling is available. |
up arrow | Scrolls content up when vertical scrolling is available. |
left | Scrolls content left when horizontal scrolling is available. |
right | Scrolls content right when horizontal scrolling is available. |