Skip to content

Sticky

Demo

Sticky 跨端示例与演示

Scroll the page to pin the month summary

May 20268 orders
Following page
#1042Shipped
¥279
#1041Completed
¥168
#1040Pending payment
¥99
#1039Completed
¥428
#1038Refunded
−¥68
#1037Completed
¥319
#1036Completed
¥86
#1035Completed
¥206

Following page · Page scroll 0px

Basic Usage

vue
<template>
  <VSticky>
    <div class="sticky-bar">Sticky Area</div>
  </VSticky>
</template>

Offset Top

vue
<template>
  <VSticky :offset-top="12" :z-index="10">
    <div class="sticky-bar">12px from top</div>
  </VSticky>
</template>

Events

vue
<template>
  <VSticky @change="fixed => console.log(fixed)" @scroll="event => console.log(event)">
    <div class="sticky-bar">Sticky Area</div>
  </VSticky>
</template>

Props

PropTypeDefaultDescription
offsetTopnumber | string0Top offset
zIndexnumber | stringundefinedZ-index
disabledbooleanfalseDisable sticky behavior

Events

EventPayloadDescription
changebooleanFixed state changed
scroll{ isFixed: boolean; scrollTop: number }Fired on page scroll

Slots

SlotDescription
defaultSticky content, with fixed slot prop

Primitives

Sticky has scroll state and events, so H5 and Weapp expose a StickyRoot primitive. Divider, Grid, Layout, and Space are static display/layout components implemented directly in the UI packages.