Scrollbar
Brief Introduction
The scrollbar is a scrollbar component that provides scrolling functionality when content exceeds the container bounds. You can use <MYScrollbar></MYScrollbar> or <MYScrollbar /> to implement a scrollbar.
About Using Local Scrollbar
Both Horizontal and Vertical Scrollbars
Enable both horizontal and vertical scrollbars with corner connection:
Code Demo
11111111111111111111111111111
<template>
<MYScrollbar widthX ScrollWidth='20px' corner>
<MYText size='30rem'>11111111111111111111111111111</MYText>
</MYScrollbar>
</template>展开代码
Scrollbar Colors
Change the colors of the scrollbar thumb, track, and hover state:
Code Demo
111111
<template>
<MYScrollbar
height='500px'
thumbColor='#ff0000'
thumbHoverColor='#2c2'
trackColor='#797'
>
<MYText size='30rem'>111</MYText>
<MYText size='30rem'>111</MYText>
</MYScrollbar>
</template>展开代码
Disable Scrolling
Disable the scrolling functionality:
Code Demo
222222
<template>
<MYScrollbar height='500px' Maxheight='800px' disabledScroll>
<MYText size='30rem'>222</MYText>
<MYText size='30rem'>222</MYText>
</MYScrollbar>
</template>展开代码
Set Maximum Height
Set the maximum height to 800px:
Code Demo
333333
<template>
<MYScrollbar height='500px' Maxheight='800px'>
<MYText size='30rem'>333</MYText>
<MYText size='30rem'>333</MYText>
</MYScrollbar>
</template>展开代码
Combined Usage
Combine multiple props:
Code Demo
444444
<template>
<MYScrollbar
height='600px'
Maxheight='1000px'
thumbColor='#fff'
thumbHoverColor='#191919'
trackColor='#2c2'
>
<MYText size='30rem'>444</MYText>
<MYText size='30rem'>444</MYText>
</MYScrollbar>
</template>展开代码
API Reference
Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| height | Scrollbar height | string | px/em/rem/dynamic | — |
| maxHeight | Maximum scrollbar height | string | px/em/rem/dynamic | — |
| ScrollWidth | Scrollbar width | string | px/em/rem/dynamic | — |
| widthX | Enable horizontal scrollbar | boolean | — | false |
| thumbColor | Thumb color | string | Hex or named color | — |
| thumbHoverColor | Thumb hover color | string | Hex or named color | — |
| trackColor | Track color | string | Hex or named color | — |
| disabledHeight | Disable vertical scrollbar | boolean | — | false |
| disabledWidth | Disable horizontal scrollbar | boolean | — | false |
| disabledScroll | Disable scrolling functionality | boolean | — | false |
| corner | Connect corner when both scrollbars are enabled | boolean | — | false |
| tag | Container tag | string | Supports all HTML tags | div |
Type Definitions
typescript
interface ScrollbarProps {
height?: string;
maxHeight?: string;
ScrollWidth?: string;
widthX?: boolean;
thumbColor?: string;
thumbHoverColor?: string;
trackColor?: string;
disabledHeight?: boolean;
disabledWidth?: boolean;
disabledScroll?: boolean;
corner?: boolean;
tag?: string;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14