{"id":18426,"date":"2022-11-09T23:18:11","date_gmt":"2022-11-09T14:18:11","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=18426"},"modified":"2024-11-17T11:24:16","modified_gmt":"2024-11-17T02:24:16","slug":"%e3%80%90react%e3%80%91%e3%80%8cmaterial-ui%e3%80%8d%e3%81%ae%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e6%89%8b%e6%b3%95","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=18426","title":{"rendered":"\u3010React\u3011\u300cMaterial-UI\u300d\u306e\u30c7\u30b6\u30a4\u30f3\u624b\u6cd5(Theme\u3001Box\u3001Container\u3001Typography\u306a\u3069\uff09"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Theme<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">import { ThemeProvider, createTheme } from \"@mui\/material\/styles\";\n\n  const apptheme = createTheme({\n    palette: {\n      mode: \"light\",\n      primary: {\n        main: \"#d87274\",\n        light: \"#ffa2a3\",\n        dark: \"#a34449\",\n      },\n    },\n  });\n\n&lt;ThemeProvider theme={apptheme}&gt;\n  &lt;div&gt;xxx&lt;\/div&gt;\n&lt;\/ThemeProvider&gt;<\/pre>\n\n\n\n<p>createTheme\u3068\u3044\u3046\u95a2\u6570\u3067theme\u3092\u4f5c\u3063\u3066\u3001ThemeProvider\u3068\u3044\u3046\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u30e9\u30c3\u30d7\u3057\u3066theme\u3092\u30bd\u30fc\u30b9\u5168\u4f53\u306b\u9069\u7528\u3055\u305b\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">palette<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">const apptheme = createTheme({\n  palette: {\n   mode: \"light\",\n   primary: {\n     main: \"#d87274\",\n     light: \"#ffa2a3\",\n     dark: \"#a34449\",\n   },\n  },\n});\n\n&lt;Button color=\"primary\"&gt;\n  primary\n&lt;\/Button&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">spacing<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b9a\u7fa9<\/h4>\n\n\n\n<p>\u5168\u3066\u306epx\u306e\u57fa\u6e96\u306b\u306a\u308a\u307e\u3059\u3002\u6307\u5b9a\u3057\u306a\u304b\u3063\u305f\u5834\u5408\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u30678px\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">const apptheme = createTheme({\n  spacing: 4,\n});<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Box\u306esx\u3078\u306e\u9069\u7528<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">margin\u3001padding<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Box sx={{ m: 2,p: 2 }}&gt;\n&lt;\/Box&gt;<\/pre>\n\n\n\n<p>2\u3068\u6307\u5b9a\u3057\u305f\u3089\u30012(\u5404DOM\u3067\u6307\u5b9a\u3057\u305fpx)*4(theme\u3067\u6307\u5b9a\u3057\u305fpx)\u306e8px\u306e\u30b9\u30da\u30fc\u30b9\u304c\u53d6\u3089\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u305d\u306e\u4ed6\u30d7\u30ed\u30d1\u30c6\u30a3\uff08width\u3001borderRadius\u306a\u3069\uff09<\/h5>\n\n\n\n<p>margin\u3001padding\u4ee5\u5916\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3061\u3087\u3063\u3068\u30c8\u30ea\u30c3\u30ad\u30fc\u306a\u6307\u5b9a\u306e\u4ed5\u65b9\u3092\u3057\u306a\u3044\u3068\u305d\u306e\u307e\u307epx\u3068\u3057\u3066\u9069\u7528\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;Box sx={{ width: (theme) =&gt; theme.spacing(8) }}&gt;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u30d6\u30ed\u30c3\u30af\u30ec\u30d9\u30eb\u8981\u7d20<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span style=\"color: #000000;\"><strong>Box\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/strong><\/span><\/h3>\n\n\n\n<p>\u666e\u901a\u306eHTML\u3067\u8a00\u3048\u3070div\u306e\u4ee3\u308f\u308a\u306b\u306a\u308a\u307e\u3059\u3002\uff08div\u3060\u3068sx\u304c\u4f7f\u3048\u306a\u3044\uff09<\/p>\n\n\n\n<p>sx Props\u3092\u76f4\u63a5\u8a18\u8ff0\u3067\u304d\u308b\u306e\u3067\u30ec\u30a4\u30a2\u30a6\u30c8\u306e\u57fa\u790e\u306b\u306a\u308a\u307e\u3059\u3002v4\u3067\u3082\u3042\u308a\u307e\u3057\u305f\u304c\u3001v5\u3067\u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u5927\u5e45\u306b\u5411\u4e0a\u3057\u305f\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<div>\n<h3>Container\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h3>\n<div>\u30b3\u30f3\u30c6\u30ca\u3092\u4e2d\u592e\u5bc4\u305b\u3059\u308b\u305f\u3081\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u3059\u3002maxWidth\u306a\u3069\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/div>\n<div>\n<pre class=\"lang:default decode:true\">&lt;Container maxWidth=\"xs\"&gt;<\/pre>\n<p>theme\u3092\u4f7f\u3048\u3070\u3001\u3069\u306e\u30d4\u30af\u30bb\u30eb\u3092\u57fa\u6e96\u306b\u3059\u308b\u304b\u306ebreakpoint\u306e\u5909\u66f4\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p><strong style=\"color: #000000;\">Stack<\/strong><span style=\"color: #000000;\">\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/span><\/p>\n<\/div>\n<\/div>\n\n\n\n<pre class=\"wp-block-preformatted\">import { Stack, Button } from \"@mui\/material\";\n\n&lt;Stack direction=\"row\" spacing={2}&gt;\n  &lt;Button variant=\"contained\" color=\"primary\"&gt;\n    primary\n  &lt;\/Button&gt;\n  &lt;Button variant=\"contained\" color=\"secondary\"&gt;\n    secondary\n  &lt;\/Button&gt;\n&lt;\/Stack&gt;<\/pre>\n\n\n\n<p>spacing\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u305d\u3046\u3059\u308c\u3070\u81ea\u52d5\u7684\u306b\u5b50\u8981\u7d20\u3092\u9593\u9694\u3092\u3042\u3051\u3066\u914d\u7f6e\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u5185\u90e8\u7684\u306b\u306fflexbox\u306e\u30b3\u30f3\u30c6\u30ca\u7684\u306a\u5f79\u5272\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30a4\u30f3\u30e9\u30a4\u30f3\u8981\u7d20<\/h2>\n\n\n\n<div>\n<h3>Typography\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h3>\n<p>\u666e\u901a\u306eHTML\u3067\u8a00\u3048\u3070span\u306e\u4ee3\u308f\u308a\u306b\u306a\u308a\u307e\u3059\u3002\uff08span\u3060\u3068sx\u304c\u4f7f\u3048\u306a\u3044\uff09<\/p>\n<p>theme\u3067\u8a2d\u5b9a\u304c\u3067\u304d\u308b\u306e\u3067theme\u901a\u308a\u306b\u30b9\u30bf\u30a4\u30ea\u30f3\u30b0\u3057\u305f\u3044\u5834\u5408\u306a\u3069\u306b\u3082\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"Theme \u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9 import { ThemeProvider, createTheme } from \"@mui\/material\/styles\"; const apptheme = createTheme( [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[116],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/18426"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18426"}],"version-history":[{"count":11,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/18426\/revisions"}],"predecessor-version":[{"id":24023,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/18426\/revisions\/24023"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18426"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}