Materialui - where to load CSS classes from?

匆匆过客 提交于 2020-07-10 10:27:12

问题


This might have a quick answer. I am starting to learn Material UI and want try its grid examples, but coding below mentions that compilation rejects as NOTFOUND .. Could not locate a CSS file to load to try these examples.. Without the className parameter, i do not see any outline of the GRID, so may be these css 'classes.root' hold the formatting options. Appreciate your kind help,

function App() {
return (
    <div className={classes.root}>  ????
      <Grid container spacing={3}>
        <Grid item xs={12}>

回答1:


You need to use makeStyles

import React from 'react';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles({
  root: {
    backgroundColor: 'red',
    color: props => props.color,
  },
});

function App(props) {
  const classes = useStyles(props);
  return (
    <div className={classes.root}>
      // ...
    </div>
  );
}


来源:https://stackoverflow.com/questions/62650170/materialui-where-to-load-css-classes-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!