Scrollbar ​

Se utiliza para reemplazar la barra de desplazamiento nativa del navegador.

Uso básico ​

Use la propiedad height para establecer la altura de la barra de desplazamiento, o si no se establece, se adapta de acuerdo a la altura del contenedor padre.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

Desplazamiento horizontal ​

Cuando el ancho del elemento es mayor que el ancho de la barra de desplazamiento, se muestra la barra de desplazamiento horizontal.

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

Scroll masks 2.14.8 ​

Use mask to indicate that more content can be scrolled to above, below, to the left, or to the right of the viewport. Masks are disabled by default.

ValorBehavior
falseDisable all masks (default).
trueEnable all four masks, according to the available overflow.
'top'Enable only the top mask.
'bottom'Enable only the bottom mask.
'left'Enable only the left mask.
'right'Enable only the right mask.
vue
<template>
  <el-scrollbar height="240px" mask />
  <el-scrollbar height="240px" mask="top" />
  <el-scrollbar height="240px" mask="bottom" />
  <el-scrollbar mask="left" />
  <el-scrollbar mask="right" />
</template>

Scroll vertically or horizontally and change the mask mode. Each enabled mask appears only while there is more content in its direction. It disappears when that edge is reached. Masks stay hidden on axes without overflow; when both axes overflow, all four masks can appear together.

Vertical scrolling

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

Horizontal scrolling

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

Masks fade in and out over 200ms by default, using --el-transition-duration-fast. The animation is disabled when the user prefers reduced motion. Masks do not block pointer events or cover scrollbar controls, and also work with native.

left and right refer to the physical edges of the viewport, including when the scroll container uses direction: rtl.

The distance attribute only affects the end-reached event; it does not change when masks appear. When using noresize, call update() after changing the content or container size to refresh the masks.

Customize masks ​

Use the following CSS variables on the Scrollbar component to customize each mask:

CSS variableDescripciónPor defecto
--el-scrollbar-top-mask-heightHeight of the top mask.40px
--el-scrollbar-bottom-mask-heightHeight of the bottom mask.40px
--el-scrollbar-left-mask-widthWidth of the left mask.40px
--el-scrollbar-right-mask-widthWidth of the right mask.40px
--el-scrollbar-top-mask-colorColor of the top mask.var(--el-bg-color)
--el-scrollbar-bottom-mask-colorColor of the bottom mask.var(--el-bg-color)
--el-scrollbar-left-mask-colorColor of the left mask.var(--el-bg-color)
--el-scrollbar-right-mask-colorColor of the right mask.var(--el-bg-color)

The default color follows the light or dark theme. Set the mask colors to match the container background when using a custom background. The example above sets the vertical mask heights and horizontal mask widths to 48px.

Altura máxima ​

La barra de desplazamiento sólo se muestra cuando la altura del elemento excede la altura máxima.

1

2

3

Desplazamiento manual ​

Use los métodos setScrollTop y setScrollLeft para controlar manualmente la barra de desplazamiento.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

Infinite scroll 2.10.0 ​

end-reached is triggered when the scrollbar reaches the end. It can be used as an infinite scroll.

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

API ​

Atributos ​

NombreDescripciónTipoPor defecto
heightaltura de la barra de desplazamientostring / number—
max-heightaltura máxima de la barra de desplazamientostring / number—
nativesi usar el estilo nativo de la barra de desplazamientobooleanfalse
wrap-styleestilo del contenedor envoltoriostring / object—
wrap-classclase del contenedor envoltoriostring—
view-styleestilo de la vistastring / object—
view-classclase de la vistastring—
noresizeno responder a los cambios de tamaño del contenedor, si el tamaño del contenedor no cambia, es mejor configurarlo para optimizar el rendimientobooleanfalse
tagetiqueta de elemento de la vistastringdiv
alwayssi mostrar siempre la barra de desplazamientobooleanfalse
mask 2.14.8Gradient masks: true for all edges, a direction for one edge, and false to disableboolean / enumfalse
min-sizetamaño mínimo de la barra de desplazamientonumber20
id 2.4.0id of viewstring—
role 2.4.0 a11yrole of viewstring—
aria-label 2.4.0 a11yaria-label of viewstring—
aria-orientation 2.4.0 a11yaria-orientation of viewenum—
tabindex 2.8.3tabindex of wrap containernumber / string—
distance 2.10.5trigger end-reached event distance(px)number0

Eventos ​

NombreDescripciónTipo
scrollse activa cuando se desplaza, regresa la distancia de desplazamientoFunction
end-reached 2.10.0triggers when the end of a scroll is triggeredFunction

Slots ​

NombreDescripción
defaultpersonaliza el contenido por defecto

Expuesto ​

NombreDescripciónTipo
handleScrollmaneja evento de desplazamientoFunction
scrollTodesplaza a un conjunto particular de coordenadasFunction
setScrollTopEstablece distancia hacia la parte superiorFunction
setScrollLeftEstablece distancia hacia la izquierdaFunction
updateactualiza el estado de la barra de desplazamiento manualmenteFunction
wrapRefreferencia de la barra de desplazamientoobject

Fuente ​

Componentes • Style • Documentación

Contribuidores ​