Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/potato4d/vue-fixed-header

Simple and cross-browser friendly fixed header component for Vue.js written by TypeScript.
https://github.com/potato4d/vue-fixed-header

javascript vue vue-components

Last synced: about 2 months ago
JSON representation

Simple and cross-browser friendly fixed header component for Vue.js written by TypeScript.

Lists

README

        

# Vue Fixed Header

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licences/MIT)
[![NPM version](https://img.shields.io/npm/v/vue-fixed-header.svg?style=flat-square)](https://npmjs.com/package/vue-fixed-header)
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors)
[![NPM downloads](https://img.shields.io/npm/dm/vue-fixed-header.svg?style=flat-square)](https://npmjs.com/package/vue-fixed-header)
[![codecov](https://codecov.io/gh/potato4d/vue-fixed-header/branch/master/graph/badge.svg)](https://codecov.io/gh/potato4d/vue-fixed-header)

Simple and cross-browser friendly fixed header component for Vue.js.

[![Image from Gyazo](https://i.gyazo.com/2511ffaabd325f76c8fe9343ba07fdcc.gif)](https://gyazo.com/2511ffaabd325f76c8fe9343ba07fdcc)

[![Edit vue-fixed-header demo](https://codesandbox.io/static/img/play-codesandbox.svg?style=flat-square)](https://codesandbox.io/s/yvjoj937x1?fontsize=14)

## Install

```bash
yarn add vue-fixed-header
```

## Usage

### Use in Single File Component

```html



import FixedHeader from 'vue-fixed-header'

export default {
components: {
FixedHeader
}
}

.navbar.vue-fixed-header--isFixed {
position: fixed;
left: 0;
top: 0;
width: 100vw;
}

```

### 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.

```html



import FixedHeader from 'vue-fixed-header'

export default {
components: {
FixedHeader
}
}

.navbar.vue-fixed-header--isFixed {
position: fixed;
left: 0;
top: 0;
width: 100vw;
}

```

### 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](https://github.com/potato4d)

## Contributors

Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):



HANATANI Takuma

πŸ’» πŸ› πŸ“– πŸ’‘ πŸ’¬ πŸ‘€

EGOIST

πŸ”§

Johnny Cavalcante

πŸ›

James Wright

πŸ›

Sid

⚠️

AndrΓ© Van Dal

πŸ’»

Patrik

πŸ›

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!