ScrollPanelScrollPanel is a cross browser, lightweight and skinnable alternative to native browser scrollbar.
Documentation
Import
import {ScrollPanelModule} from 'primeng/scrollpanel';
Getting Started
ScrollPanel is defined with p-scrolPanel element having dimensions for the scrollable viewport.
<p-scrollPanel [style]="{width: '100%', height: '200px'}">
Content
</p-scrollPanel>
Customization
Look and feel can easily be customized, here is an example with a background and blue handle.
<p-scrollPanel [style]="{width: '100%', height: '200px'}" styleClass="custom">
Content
</p-scrollPanel>
.custom .ui-scrollpanel-wrapper {
border-right: 9px solid #f4f4f4;
}
.custom .ui-scrollpanel-bar {
background-color: #1976d2;
opacity: 1;
transition: background-color .3s;
}
.custom .ui-scrollpanel-bar:hover {
background-color: #135ba1;
}
Properties
Name | Type | Default | Description |
---|---|---|---|
style | string | null | Inline style of the component. |
styleClass | string | null | Style class of the component. |
Styling
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
ui-scrollpanel | Container element. |
ui-scrollpanel-wrapper | Wrapper of content section. |
ui-scrollpanel-content | Content section. |
ui-scrollpanel-bar | Scrollbar handle. |
ui-scrollpanel-bar-x | Scrollbar handle of a horizontal bar. |
ui-scrollpanel-bar-y | Scrollbar handle of a vertical bar |
Methods
Name | Parameters | Description |
---|---|---|
refresh | - | Refreshes the position and size of the scrollbar. |
scrollTop | value: number | Scrolls the top location to the given value. |
Dependencies
None.
Source
<div class="ui-g">
<div class="ui-g-12 ui-md-4">
<p-scrollPanel [style]="{width: '100%', height: '200px'}">
<div style="padding:1em;line-height:1.5">
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding. His beloved
son Michael has just come home from the war, but does not intend to become part of his father's business.
Through Michael's life the nature of the family business becomes clear. The business of the family is just
like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence
whenever anything stands against the good of the family. The story begins as Don Vito Corleone, the head
of a New York Mafia family, oversees his daughter's wedding. His beloved son Michael has just come home from
the war, but does not intend to become part of his father's business. Through Michael's life the nature of
the family business becomes clear. The business of the family is just like the head of the family, kind and
benevolent to those who give respect, but given to ruthless violence whenever anything stands against the
good of the family.
</div>
</p-scrollPanel>
</div>
<div class="ui-g-12 ui-md-4">
<p-scrollPanel [style]="{width: '100%', height: '200px'}" styleClass="custombar1">
<div style="padding:1em;line-height:1.5">
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding. His beloved
son Michael has just come home from the war, but does not intend to become part of his father's business.
Through Michael's life the nature of the family business becomes clear. The business of the family is just
like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence
whenever anything stands against the good of the family. The story begins as Don Vito Corleone, the head
of a New York Mafia family, oversees his daughter's wedding. His beloved son Michael has just come home from
the war, but does not intend to become part of his father's business. Through Michael's life the nature of
the family business becomes clear. The business of the family is just like the head of the family, kind and
benevolent to those who give respect, but given to ruthless violence whenever anything stands against the
good of the family.
</div>
</p-scrollPanel>
</div>
<div class="ui-g-12 ui-md-4">
<p-scrollPanel [style]="{width: '100%', height: '200px'}" styleClass="custombar2">
<div style="padding:1em;line-height:1.5;width:600px;">
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding. His beloved
son Michael has just come home from the war, but does not intend to become part of his father's business.
Through Michael's life the nature of the family business becomes clear. The business of the family is just
like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence
whenever anything stands against the good of the family. The story begins as Don Vito Corleone, the head
of a New York Mafia family, oversees his daughter's wedding. His beloved son Michael has just come home from
the war, but does not intend to become part of his father's business. Through Michael's life the nature of
the family business becomes clear. The business of the family is just like the head of the family, kind and
benevolent to those who give respect, but given to ruthless violence whenever anything stands against the
good of the family.
</div>
</p-scrollPanel>
</div>
</div>
@Component({
templateUrl: './scrollpaneldemo.html',
styles: [`
.custombar1 .ui-scrollpanel-wrapper {
border-right: 9px solid #f4f4f4;
}
.custombar1 .ui-scrollpanel-bar {
background-color: #1976d2;
opacity: 1;
transition: background-color .3s;
}
.custombar1 .ui-scrollpanel-bar:hover {
background-color: #135ba1;
}
.custombar2 .ui-scrollpanel-wrapper {
border-right: 9px solid #757575;
border-bottom: 9px solid #757575;
}
.custombar2 .ui-scrollpanel-bar {
background-color: #68C77D;
border-radius: 0;
opacity: 1;
transition: background-color .3s;
}
.custombar2:hover .ui-scrollpanel-bar {
background-color: #46A55A;
}
`],
encapsulation: ViewEncapsulation.None
})
export class ScrollPanelDemo {
}