Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
4
Help us understand the problem. What is going on with this article?

More than 1 year has passed since last update.

@morry_48

[React] makeStyles / createStyles の使い方

makeStyles,
createStyles
をimportし、useStylesを定義


import { makeStyles, createStyles } from '@material-ui/core/styles';   //style関連のimport



const useStyles = makeStyles((theme) => createStyles({  //useStylesを定義
    card: {
        margin: theme.spacing(5),
        padding: theme.spacing(3),
    },
}));

function Home() {

    const classes = useStyles();  //コンポーネント内でuseStylesを使用し、classesを定義

classesをreturnの中のjsxで使用する

    return (
        <div className="container">
            <div className="row justify-content-center">
                <div className="col-md-8">
                    <div className="card">
                        <h1>タスク管理</h1>
                        <Card className={classes.card}>     //return内でstyleを呼び出す



以上、備忘録

ReactではComponentごとにstyleを定義するのが一般的かと思います。

4
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
4
Help us understand the problem. What is going on with this article?