How to style Material-UI's tooltip?

前端 未结 5 1904
栀梦
栀梦 2020-12-14 16:01

How can I style Material-UI\'s tooltip text? The default tooltip on hover comes out black with no text-wrap. Is it possible to change the background, color etc? Is this opti

5条回答
  •  离开以前
    2020-12-14 16:47

    I ran into this issue as well, and want for anyone seeking to simply change the color of their tooltip to see this solution that worked for me:

    import React from 'react';
    import { makeStyles } from '@material-ui/core/styles';
    
    import Tooltip from '@material-ui/core/Tooltip';
    import Button from '@material-ui/core/Button';
    import DeleteIcon from '@material-ui/icons/Delete';
    
    const useStyles = makeStyles(theme => ({
      customTooltip: {
        // I used the rgba color for the standard "secondary" color
        backgroundColor: 'rgba(220, 0, 78, 0.8)',
      },
      customArrow: {
        color: 'rgba(220, 0, 78, 0.8)',
      },
    });
    
    export default TooltipExample = () => {
      const classes = useStyles();
    
      return (
        <>
          
            
          
        
      );
    };
    

提交回复
热议问题