Skip to content

littletime/react-hooks-use-shrinkable-header

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

react-hooks-use-shrinkable-header

Your shrinkable header state in one hook

Window listeners managed for you

This hook listens to the window scroll event and sets your state accordingly.

Installation

npm i --save react-hooks-use-shrinkable-header

Usage

import React from 'react'
import useShrinkableHeader from 'react-hooks-use-shrinkable-header'

const Header = () => {
  // If you want to set your own scroll threshold for shrinking the header,
  // you can pass it to the hook as a param
  const shrinked = useShrinkableHeader()
  
  return (
    <div className={shrinked ? 'shrinked' : ''}>
      My header
    </div>
  )
}

About

Your shrinkable header state in one hook

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published