vue-fixed-header
Vue Fixed Header
Simple and cross-browser friendly fixed header component for Vue.js.
Install
yarn add vue-fixed-header
Usage
Use in Single File Component
<template>
<fixed-header>
<div class="navbar">
Your Content
</div>
</fixed-header>
</template>
<script>
import FixedHeader from 'vue-fixed-header'
export default {
components: {
FixedHeader
}
}
</script>
<style>
.navbar.vue-fixed-header--isFixed {
position: fixed;
left: 0;
top: 0;
width: 100vw;
}
</style>
Attach classes
The Vue Fixed Header always assigns the vue-fixed-header CSS class to the slot's root element.
Also, when matching the fixed condition, we give the vue-fixed-header - isFixed CSS class.
These can also be changed with headerClass prop and fixedClass prop.
Props
threshold: number
The threshold value for determining the scroll state.
<template>
<fixed-header :threshold="100">
<div class="navbar">
Your Content
</div>
</fixed-header>
</template>
<script>
import FixedHeader from 'vue-fixed-header'
export default {
components: {
FixedHeader
}
}
</script>
<style>
.navbar.vue-fixed-header--isFixed {
position: fixed;
left: 0;
top: 0;
width: 100vw;
}
</style>
headerClass
CSS class for fixed-header root Element. It is always attached to fixed header root Element.
- type: String,
- required: false
- default: 'vue-fixed-header'
fixedClass
CSS class for fixed header. When fixed-header position is relative, it removed to DOM Element. When fixed-header position is fixed, it added to DOM Element.
- type: String
- required: false
- default: 'vue-fixed-header--isFixed'
License
MIT © potato4d
Contributors
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Related Packages
Vue.js 2.0 组件级懒加载方案 Vue.js 2.x component level lazy loading solution
A lightweight Vue 3 component library supporting Google reCAPTCHA v2 and v3 inte...
Version History
| Version | Released | License |
|---|---|---|
| 3.2.15 | ||
| 3.2.14 | ||
| 3.2.13 | ||
| 3.2.12 | ||
| 3.2.11 | ||
| 3.2.10 | ||
| 3.2.9 | ||
| 3.2.8 | ||
| 3.2.7 | MIT | |
| 3.2.6 | MIT | |
| 3.2.4 | MIT | |
| 3.2.3 | MIT | |
| 3.2.2 | MIT | |
| 3.2.0 | MIT | |
| 3.1.3 | MIT | |
| 3.1.2 | MIT | |
| 3.1.1 | MIT | |
| 3.1.0 | MIT | |
| 3.0.0 | MIT | |
| 2.0.2 | MIT | |
| 2.0.1 | MIT | |
| 2.0.0 | MIT | |
| 1.0.5 | MIT | |
| 1.0.4 | MIT | |
| 1.0.3 | MIT | |
| 1.0.2 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | MIT | |
| 0.1.0 | MIT |
Pre-releases (2)
| Version | Released | License |
|---|---|---|
| 3.0.0-beta.2 | MIT | |
| 3.0.0-beta.1 | MIT |
