@material-ui/stylesのmakeStyles
5653 ワード
./components/ui/Header.js
import { AppBar, Toolbar, Typography } from "@material-ui/core";
import React from "react";
import useScrollTrigger from "@material-ui/core/useScrollTrigger";
import { makeStyles } from "@material-ui/styles";
function ElevationScroll(props) {
const { children, window } = props;
const trigger = useScrollTrigger({
disableHysteresis: true,
threshold: 0,
target: window ? window() : undefined,
});
return React.cloneElement(children, {
elevation: trigger ? 4 : 0,
});
}
const useStyles = makeStyles((theme) => ({
toolbarMargin: {
...theme.mixins.toolbar,
},
}));
const Header = () => {
const classes = useStyles();
return (
<React.Fragment>
<ElevationScroll>
<AppBar>
<Toolbar>
<Typography variant="h3">Header</Typography>
</Toolbar>
</AppBar>
</ElevationScroll>
<div className={classes.toolbarMargin} />
</React.Fragment>
);
};
export default Header;
Author And Source
この問題について(@material-ui/stylesのmakeStyles), 我々は、より多くの情報をここで見つけました https://qiita.com/yono2844/items/4b99de42d4d785c7c6f3著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .