Material-ui: ์‚ฌ์šฉ์ž ์ •์˜ ๊ธ€๊ผด ๋ณ€๊ฒฝ/์‚ฌ์šฉ

์— ๋งŒ๋“  2016๋…„ 04์›” 07์ผ  ยท  7์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: mui-org/material-ui

์™œ material-ui์™€ ํ•จ๊ป˜ ๋ฒˆ๋“ค๋กœ ์ œ๊ณต๋˜๋Š” ๊ธ€๊ผด์„ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๊นŒ?

์ด๊ฒƒ์„ ์ œ๊ฑฐํ•˜๊ฑฐ๋‚˜ ๊ตฌ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๊นŒ?

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์‹ค์ œ๋กœ 6์‹œ๊ฐ„ ๋™์•ˆ ์˜จ๋ผ์ธ์—์„œ ๊ฒ€์ƒ‰ํ•˜๊ณ  lib ์ฝ”๋“œ๋ฅผ ํŒŒํ—ค์น˜๊ณ  ๋ฌด์ž‘์œ„๋กœ ์ถ”์ธกํ•œ ํ›„ ๋‚ด๊ฐ€ ๋„๋‹ฌํ•œ ๊ฒฐ๋ก ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. IT IS POSIBLE! :๋””

  1. /public์— /font ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ
  2. @font-faces๋ฅผ ์ •์˜ํ•˜๋Š” /public/fonts/fonts.css ์ƒ์„ฑ:
@font-face {
  font-family: 'inglobal';
  font-weight: normal;
  font-style: normal;
  src: url('./inglobal.ttf');
}
  1. <link rel="stylesheet" href="%PUBLIC_URL%/fonts/fonts.css"> ๋ฅผ /public/index.html์˜ ํ—ค๋“œ์— ์ถ”๊ฐ€

  2. ๋งŒ์„ธ!

4/๋‚˜. ์–ด๋–ค ์ด์œ ๋กœ๋“  ์—ฌ์ „ํžˆ ์ž‘๋™ํ•˜์ง€ ์•Š์œผ๋ฉด ๊ธ€๊ผด ํ™•์žฅ์ž๋ฅผ .css( src: url('./OperatorMono.css') ์—์„œ๋„)๋กœ ๋ณ€๊ฒฝํ•˜์‹ญ์‹œ์˜ค.

๋ชจ๋“  7 ๋Œ“๊ธ€

์‹ค์ œ๋กœ 6์‹œ๊ฐ„ ๋™์•ˆ ์˜จ๋ผ์ธ์—์„œ ๊ฒ€์ƒ‰ํ•˜๊ณ  lib ์ฝ”๋“œ๋ฅผ ํŒŒํ—ค์น˜๊ณ  ๋ฌด์ž‘์œ„๋กœ ์ถ”์ธกํ•œ ํ›„ ๋‚ด๊ฐ€ ๋„๋‹ฌํ•œ ๊ฒฐ๋ก ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. IT IS POSIBLE! :๋””

  1. /public์— /font ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ
  2. @font-faces๋ฅผ ์ •์˜ํ•˜๋Š” /public/fonts/fonts.css ์ƒ์„ฑ:
@font-face {
  font-family: 'inglobal';
  font-weight: normal;
  font-style: normal;
  src: url('./inglobal.ttf');
}
  1. <link rel="stylesheet" href="%PUBLIC_URL%/fonts/fonts.css"> ๋ฅผ /public/index.html์˜ ํ—ค๋“œ์— ์ถ”๊ฐ€

  2. ๋งŒ์„ธ!

4/๋‚˜. ์–ด๋–ค ์ด์œ ๋กœ๋“  ์—ฌ์ „ํžˆ ์ž‘๋™ํ•˜์ง€ ์•Š์œผ๋ฉด ๊ธ€๊ผด ํ™•์žฅ์ž๋ฅผ .css( src: url('./OperatorMono.css') ์—์„œ๋„)๋กœ ๋ณ€๊ฒฝํ•˜์‹ญ์‹œ์˜ค.

  1. index.html์— Google ๊ธ€๊ผด์„ ์—ฐ๊ฒฐํ•˜์„ธ์š”.
    <link href="https://fonts.googleapis.com/css?family=Montserrat:400,500,700&display=swap" rel="stylesheet">

  2. ๋‹น์‹ ์˜ ๋ฐ”๋”” ์Šคํƒ€์ผ์— ์ถ”๊ฐ€
    /* Styles */ body { margin: 0 auto; font-family: 'Montserrat'; }

  3. app.js์˜ ๋ช‡ ๊ฐ€์ง€ ๋ณ€๊ฒฝ ์‚ฌํ•ญ
    import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';

const theme = createMuiTheme({ typography: { fontFamily: [ 'Montserrat' ].join(','), }, })

/public/index.html


๋‚˜๋ฅผ ์œ„ํ•ด ์ผํ–ˆ์Šต๋‹ˆ๋‹ค :)

์‹ค์ œ๋กœ 6์‹œ๊ฐ„ ๋™์•ˆ ์˜จ๋ผ์ธ์—์„œ ๊ฒ€์ƒ‰ํ•˜๊ณ  lib ์ฝ”๋“œ๋ฅผ ํŒŒํ—ค์น˜๊ณ  ๋ฌด์ž‘์œ„๋กœ ์ถ”์ธกํ•œ ํ›„ ๋‚ด๊ฐ€ ๋„๋‹ฌํ•œ ๊ฒฐ๋ก ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. IT IS POSIBLE! :๋””

  1. /public์— /font ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ
  2. @font-faces๋ฅผ ์ •์˜ํ•˜๋Š” /public/fonts/fonts.css ์ƒ์„ฑ:
@font-face {
  font-family: 'inglobal';
  font-weight: normal;
  font-style: normal;
  src: url('./inglobal.ttf');
}
  1. <link rel="stylesheet" href="%PUBLIC_URL%/fonts/fonts.css"> ๋ฅผ /public/index.html์˜ ํ—ค๋“œ์— ์ถ”๊ฐ€
  2. ๋งŒ์„ธ!

4/๋‚˜. ์–ด๋–ค ์ด์œ ๋กœ๋“  ์—ฌ์ „ํžˆ ์ž‘๋™ํ•˜์ง€ ์•Š์œผ๋ฉด ๊ธ€๊ผด ํ™•์žฅ์ž๋ฅผ .css( src: url('./OperatorMono.css') ์—์„œ๋„)๋กœ ๋ณ€๊ฒฝํ•˜์‹ญ์‹œ์˜ค.

์ผ์ด์•ผ!! ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

๊ธฐ๋ณธ ๊ธ€๊ผด์„ ๋ณ€๊ฒฝํ•˜๋ ค๋ฉด ๋‹ค์Œ 2๋‹จ๊ณ„๋ฅผ ๋”ฐ๋ฅด์‹ญ์‹œ์˜ค.

์—ฌ๊ธฐ์—์„œ ๊ธฐ๋ณธ ๊ธ€๊ผด์„ "Open Sans"๋กœ ๋ณ€๊ฒฝํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

  1. index.html์—์„œ Google ๊ธ€๊ผด ๊ฐ€์ ธ์˜ค๊ธฐ
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap" rel="stylesheet"/>

  2. index.js์—์„œ ์ด๋Ÿฌํ•œ ๋ณ€๊ฒฝ์„ ์ˆ˜ํ–‰ํ•˜์‹ญ์‹œ์˜ค.

import { ThemeProvider } from '@material-ui/styles';
import { CssBaseline } from '@material-ui/core';
import { createMuiTheme } from '@material-ui/core';

const theme = createMuiTheme({ typography: { fontFamily: [ 'Open Sans' ].join(','), }, })

ReactDOM.render(
        <ThemeProvider theme={theme}>
                        <CssBaseline />
            <App />
        </ThemeProvider>,
    document.getElementById('root')
);

_๊ตฌ์„ฑ ์ค‘์— ์‹œํ€€์Šค๊ฐ€ โ€‹โ€‹์ค‘์š”ํ•œ ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. createMuiTheme ์—์„œ ๊ตฌ์„ฑํ•˜๋Š” ๋™์•ˆ ํ•ญ์ƒ ์ตœ์ƒ์œ„ ์ˆ˜์ค€์—์„œ ํƒ€์ดํฌ๊ทธ๋ž˜ํ”ผ๋ฅผ ์ •์˜ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

๋ฌธ์ œ:

๊ตฌ์„ฑ ํ…Œ๋งˆ์— ๊ธ€๊ผด ๋ชจ์Œ์ด ํ‘œ์‹œ๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ

// Create a theme instance.
const theme = createMuiTheme({
  palette: {
    primary: {
      main: "#2991d6",
    },
    secondary: {
      main: "#19857b",
    },
    error: {
      main: red.A400,
    },
    background: {
      default: "#fff",
    },
  }, typography: {
    fontFamily: "VarelaRound,sans-serif",
  },
  overrides: {
    MuiCssBaseline: {
      "@global": {
        "@font-face": [varelaRound],
      },
    },
  },
});

Note: In this case Material UI using Roboto as the default font


ํ•ด๊ฒฐ์ฑ…:

// Create a theme instance.
const theme = createMuiTheme({
  typography: {
    fontFamily: "VarelaRound,sans-serif",
  },
  palette: {
    primary: {
      main: "#2991d6",
    },
    secondary: {
      main: "#19857b",
    },
    error: {
      main: red.A400,
    },
    background: {
      default: "#fff",
    },
  },
  overrides: {
    MuiCssBaseline: {
      "@global": {
        "@font-face": [varelaRound],
      },
    },
  },
});

๋‚˜๋Š” ์ˆœ์„œ๋ฅผ ๋ณ€๊ฒฝํ•˜๊ณ  ๋ชจ๋“  ๊ฒƒ์ด ์ž˜ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰