material-uireact-typescript

Put an icon inside a circle


enter image description here

I am doing a project, but this project has a verification email page, and I want to put an email icon at the beginning of this interface, but around a circle and I could not? How can I put an icon around a circle?


Solution

  • Use an Icon Avatar. Documentation here.

    Here's a working CodeSandbox.

    Example:

    import React from 'react';
    import { makeStyles } from '@material-ui/core/styles';
    import Avatar from '@material-ui/core/Avatar';
    import EmailIcon from '@material-ui/icons/Email';
    
    const useStyles = makeStyles((theme) => ({
      avatar: {
        backgroundColor: theme.palette.grey[50],
        border: `1px solid ${theme.palette.info.main}`,
        color: theme.palette.info.main,
      },
    }));
    
    export default function EmailAvatar() {
      const classes = useStyles();
      return (
        <Avatar className={classes.avatar}>
          <EmailIcon />
        </Avatar>
      );
    }