简体   繁体   English

如何在 Material UI 快速拨号按钮中添加文本?

[英]How to add a text into Material UI speed dial button?

How to change the material ui speeddial button, apparently it uses the Fab default and all you can do is to change the Icon, but I need to add a text as well, for example:如何更改材质ui快速拨号按钮,显然它使用Fab默认值,您所能做的就是更改Icon,但我还需要添加一个文本,例如:

<Fab variant="extended">
    <NavigationIcon />
    Actions
</Fab>

Use SpeedDialAction for this purpose为此目的使用SpeedDialAction

<SpeedDialAction
   key={action.name}
   icon={action.icon} // here goes your icon
   tooltipTitle={action.name} // here goes your text
   tooltipOpen
   onClick={handleClose}
/>

On hover you will see在 hover 你会看到在此处输入图像描述


Please, let me know if it works for you or not )请让我知道它是否适合您)

Sorry that this is late, but I recently ran into this problem and found the solution:抱歉,这已经晚了,但我最近遇到了这个问题并找到了解决方案:

SpeedDial comes with FabProps prop to enable you to modify the Fab (Fab docs: https://mui.com/material-ui/api/fab/ ). SpeedDial附带FabProps道具,使您能够修改 Fab(Fab 文档: https://mui.com/material-ui/api/fab/ )。
So firstly you should modify the Fab to use variant="extended" .所以首先你应该修改Fab以使用variant="extended" Then to add your text, use the icon prop from SpeedDialIcon .然后添加您的文本,使用来自SpeedDialIconicon道具。

So your component should look something like this:所以你的组件应该是这样的:

<SpeedDial
  FabProps={{ variant: "extended" }}
  icon={
    <SpeedDialIcon
      icon={
        <Box sx={{ display: "flex" }}>
          <YourIcon />
          <Typography> {/* Your text */} </Typography>
        </Box>
    />
  }
/>

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

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