In my Header.js
component, I have two AppBars. The first one is sticky and the second one is not initially visible. As we scroll down, I want the second AppBar to collapse and the first one to stay stickied at the top of the screen.
I looked at the Material-UI documentation and found the useScrollTrigger()
method, but it only provides guidance on hiding an AppBar on scroll.
// Header.js
import React from "react";
import { AppBar, Toolbar, Typography } from "@material-ui/core";
export default function Header() {
return (
<>
<AppBar position="static">
<Toolbar>
<Typography variant="h6">First AppBar</Typography>
</Toolbar>
</AppBar>
<AppBar position="static">
<Toolbar>
<Typography variant="h6">Second AppBar</Typography>
</Toolbar>
</AppBar>
</>
);
}
You can view my sandbox example here.