Koras02
Koras02코딩웹
Koras02
전체 방문자
오늘
어제
  • 분류 전체보기 (299)
    • 백엔드 (59)
      • nestjs (2)
      • Ruby (3)
      • PostgresQL (11)
      • MySQL (5)
      • Haskell (7)
      • Koa (3)
      • Java (3)
      • Python (5)
      • Rust (5)
      • MongoDB (2)
      • PHP (3)
      • Spring Boot (1)
      • redis (5)
      • deno (2)
    • 웹서버 (3)
      • nginx (1)
      • Apache (2)
      • Google Web Server (0)
    • 모바일개발 (5)
      • Figma (0)
      • React Native (2)
      • swift (0)
      • Flutter (3)
      • Kotlin (0)
    • 프론트 엔드 (158)
      • HTML (34)
      • CSS (7)
      • Javascript (35)
      • Angular (0)
      • Typescript (2)
      • React (58)
      • Vue (2)
      • GIT (6)
      • GraphQL (1)
      • Doker (4)
      • Go (8)
      • svelte (1)
      • gatsby (0)
    • etc. (47)
      • Notion (0)
      • TIL (24)
      • Algorithm (17)
      • Algorithm 개념 정리 (2)
      • Wiki (3)
      • Official document (1)
    • 웹개념 (12)
    • 변수정리 (1)
    • VSCode (2)
    • 포트폴리오 분석 (2)
      • React (2)
    • os (5)
      • 윈도우 (4)
      • Mac (0)
      • 가상머신 (0)
      • linux (1)
    • 응용프로그램언어 (2)
      • C (2)
      • C++ (0)
      • C# (0)
    • 블로그 운영관련 (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록
글쓰기

공지사항

  • [공지사항] 개발 이슈나 공식문서 업데이트 업로드 예정입니⋯

인기 글

태그

  • 프로그래머스
  • html
  • 데이터 타입
  • 알고리즘
  • mysql
  • Java
  • 하스켈
  • go
  • javascript
  • Haskell
  • React
  • Til
  • html5
  • redis
  • koa
  • Flutter
  • Rust
  • CSS
  • 문자열
  • PostgreSQL

티스토리

최근 댓글

최근 글

250x250
hELLO · Designed By 정상우.
Koras02

Koras02코딩웹

[Material-Ui] React에서 자주사용하는 스타일 UI라이브러리
프론트 엔드/React

[Material-Ui] React에서 자주사용하는 스타일 UI라이브러리

2021. 8. 31. 17:29
728x90

이번 시간에는 React에서 자주 사용하는 기능/디자인들을 Compnent/Api로 제공해서, Reacr 개발시 다양한 UI를 만들어주는 Meterial-ui 에 대해 알아보도록 하겠습니다.

 

1. Material-UI 시작하기

<설치>

       

  • @material-ui/core
// npm 사용시
npm install @material-ui/core

// yarn 사용시
yarn add @material-ui/core

 

  • @material-ul/icons
// npm 사용시
npm install @material-ui/icons

// yarn 사용시
yarn add @material-ui/icons

 

meterial에서 제공하는 icon도 다운받아줍니다.

 


<import>

material-ui을 불러오기위해 아래 명령어른 입력한다.

import React from 'react'
import PropTypes from "prop-types";
import { makeStyles } from "@material-ui/core/styles";
import AppBar from '@material-ui/core/AppBar';
import Tabs from "@material-ui/core/Tabs";
import Tab from "@material-ui/core/Tab";
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';

function TbaPannel(props) {
  const {children, value, index,...other} = props

  return (
    <div 
    role="tabpanel"
    hidden={value !== index}
    id={`simple-tabpanel-${index}`}
    aria-labelledby={`simple-tab-${index}`}
    {...other}

    >
      {value === index && (
        <Box p={3}>
          <Typography>{children}</Typography>
        </Box>
      )}
    </div>
  );
}

TbaPannel.a11yProps = {
  children: PropTypes.node,
  index: PropTypes.any.isRequired,
  value: PropTypes.any.isRequired,
}

function a11yProps(index) {
  return {
    id: `simple-tab-${index}`,
    'aria-controls' : `simple-tabpannel-${index}`
  }
}


const useStyles = makeStyles((theme) => ({
  root : {
    flexGrow: 1,
    backgroundColor: theme.palette.background.paper,
  }
}))
export default function SimpleTabs() {
  const classes = useStyles();
  const [value, setValue] = React.useState(0);

  const handleChange = (event, newValue) => {
    setValue(newValue);
  }

  return (
    <div className={classes.root}>
      <AppBar position="static">
        <Tabs value={value} onChange={handleChange} arial-label="simple tabs example">
           <Tab label="Item One" {...a11yProps(0)} />
           <Tab label="Item Tow" {...a11yProps(1)} /> 
           <Tab label="Item Three" {...a11yProps(2)} /> 
        </Tabs>
      </AppBar>
      <TbaPannel value={value} index={0}>
        Item One
      </TbaPannel>
      <TbaPannel value={value} index={1}>
        Item Two
      </TbaPannel>
      <TbaPannel value={value} index={2}>
        Item Three
      </TbaPannel>
    </div>
  )

}

공식튜토리얼에 나온 간단한 예제입니다.

 

전 페이지에 MovieApi로 영화 리스트를 불러왔습니다 .이렇게 간단하고 심플한 디자인 메뉴를 만들수 있는 것이 가장 큰 장점입니다.

 

 

'프론트 엔드 > React' 카테고리의 다른 글

[heroku] React Heroku 배포하기  (0) 2021.08.31
[React] Firebase 배포하기  (0) 2021.08.31
Js와 tsx,ts의 차이점  (2) 2021.08.31
    '프론트 엔드/React' 카테고리의 다른 글
    • [React+Node.js] Node.js(Express)연동하기 - 3.다시한번 도전!
    • [heroku] React Heroku 배포하기
    • [React] Firebase 배포하기
    • Js와 tsx,ts의 차이점
    Koras02
    Koras02
    현재 사용중인 언어 - next-js,react,vue, typescript

    티스토리툴바