Atomic Habits

[React] MUI - custom SVG Icon 만들기 본문

IT/React

[React] MUI - custom SVG Icon 만들기

체계성 2021. 11. 15. 22:36

 

 

[MyIcon.jsx]
import React from 'react'
import { Icon } from "@material-ui/core";
import ICONS   from '../../imgs/playbtn.svg';


// 방법1
const Logo = () => (
  <Icon className="exIcon" style={{width: '100%', height: '100%', color: "red"}} >
    <img  src={ICONS} height={20} width={20}/>
  </Icon>
);
export default Logo;

// 방법2
// const Logo = () => {
//   return (
//       <Icon style={{width: '100%', height: '100%', color: "red"}} >
//         <img className="exIcon" src={ICONS} height={20} width={20}/>
//       </Icon>
//     )
// }
// export default Logo;

// 방법3
// export default function Logo() {
//   return (
//       <Icon style={{width: '100%', height: '100%', color: "red"}} >
//         <img className="exIcon" src={ICONS} height={20} width={20}/>
//       </Icon>
//   )
// }

 

[ShowIcon.jsx]
import * as React from 'react';
import LoadingButton from '@mui/lab/LoadingButton';
import Box from '@mui/material/Box';
import FormControlLabel from '@mui/material/FormControlLabel';
import Switch from '@mui/material/Switch';
import SaveIcon from '@mui/icons-material/Save';

import starIcon  from '../../imgs/star.png';

import Logo from "./MyIcon";

export default function   LoadingButtonsTransitionEx() {
  const [loading, setLoading] = React.useState(false);
  function handleClick() {
    setLoading(true);
  }

  return (
    <Box sx={{ '& > button': { m: 1 } }}>

      <LoadingButton
        onClick={handleClick}
        startIcon={<Logo />}       ★
        endIcon={<SaveIcon />}     ★
        loading={loading}
        loadingPosition="end"
        variant="contained"
      >
        Send
      </LoadingButton>


      <img src={ starIcon} alt="ddd" />
    </Box>
  );
}

 

'IT > React' 카테고리의 다른 글

리액트 부트스트랩(Bootstrap)  (0) 2021.11.18
React. Part2. ch3. 13. Tailwindcss  (0) 2021.11.16
React. Part2. ch3. 10~12. Material UI 1,2,3  (0) 2021.11.14
[VS CODE] React Code Snippets  (0) 2021.11.14
[checkAll] ! ! list .length ? boolean ?  (0) 2021.11.14
Comments