How to make AppBar component from material-ui-next react to scroll events

前端 未结 3 908
说谎
说谎 2021-02-09 08:40

As per Material Design guidelines:

Upon scrolling, the top app bar can […] transform in the following ways:
- Scrolling upward hides the top app bar

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-09 09:19

    in the current version of Material-ui, you can simply use the following

    import clsx from "clsx";
    import useScrollTrigger from "@material-ui/core/useScrollTrigger";
    const trigger = useScrollTrigger();
    
    
    
    

    https://material-ui.com/components/app-bar/#usescrolltrigger-options-trigger

提交回复
热议问题