Sticky

Bootstrap 5 Sticky

Sticky is a directive which allows elements to be locked in a particular area of the page. It is often used in navigation menus.

Note: Read the API tab to find all available options and advanced customization


Basic example

To start use sticky just add a v-mdb-stickydirective to the element you want to pin


Sticky bottom

You can pin element to bottom by adding v-mdb-sticky="{ position: 'bottom' }"


Boundary

Set v-mdb-sticky="{ boundary: true }" so that sticky only works inside the parent element. Remember to set the correct parent height.


Outer element as a boundary

You can specify an element selector to be the sticky boundary.

Stop here

Direction

Default direction of sticky component is down. You can change it by setting v-mdb-sticky="{ direction: 'up' }" or v-mdb-sticky="{ direction: 'both' }"


Animation

You can add an animation that will run when the sticky starts and when the sticky element is hidden. just specify the css class of the animation using the v-mdb-sticky="{ animationSticky: 'animation-name' }" and v-mdb-sticky="{ animationUnsticky: 'animation-name' }".

Remember that not every animation will be appropriate. We suggest using the animations used in the example below.


Sticky with navbar

By default, sticky locks the element at the edge of the screen. If you have a navbar element on your website, it will hide behind it. You can prevent this by setting an v-mdb-sticky="{ offset: number }" or v-mdb-sticky="{ delay: number }"

Sticky - API


Import


        import { mdbSticky } from "mdb-vue-ui-kit";
      

Properties

Property Type Default Description
animationSticky String '' Set sticky animation
animationUnsticky String '' Set unsticky animation
boundary Boolean false set to true to stop sticky on the end of the parent
delay Number 0 Set the number of pixels beyond which the item will be pinned
direction String 'down' Set the scrolling direction for which the element is to be stikcky
media Number 0 Set the minimum width in pixels for which the sticky should work
offset Number 0 Set the distance from the top edge of the element for which the element is sticky
position String 'top' Set the edge of the screen the item should stick to