简体   繁体   English

如何在 ReactJS 中的 IconButton 附近 position 材质 UI 徽章?

[英]How to position Material UI badge near IconButton in ReactJS?

How can I solve the issue of positioning the badge content to be near the IconButton in Material UI?如何解决在 Material UI 中将徽章内容定位在 IconButton 附近的问题?

I've tried to disableRipple but it doesn't work!我试图禁用Ripple,但它不起作用!

Ugly丑陋的在此处输入图像描述

     <Badge badgeContent={4} color="primary">
          <IconButton
            disableFocusRipple
            disableRipple
            style={{ backgroundColor: "transparent" }}
          >
            <MailIcon />
          </IconButton>
        </Badge>

How I want to appear我想如何出现在此处输入图像描述

If I don't use IconButton everything is okay, but I need Icon Button!如果我不使用 IconButton 一切都好,但我需要 Icon Button!

Put the IconButton outside of the Badge将 IconButton 放在徽章之外

 <IconButton style={{ backgroundColor: "transparent" }}>
      <Badge badgeContent={4} color="primary">
           <MailIcon />
      </Badge>
   </IconButton>

Result结果在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM