Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138249

display text instead of icon on mouseover - React material ui button

$
0
0

I am using material ui button in my project. Initially the add button is having only + icon.

When the mouse is hovered I need to change the content of button from the icon to the text "CREATE ITEM"

The code is as follows.

import Fab from '@material-ui/core/Fab';
import AddIcon from '@material-ui/icons/Add';
import { makeStyles } from '@material-ui/core/styles';
const useStyles = makeStyles(theme => ({
  iconHover: {
    '&:hover': {
      border: '2px solid green',
      //TODO display the text CREATE ITEM instead of AddIcon
    }
  },

  floatBtn: {
    marginRight: theme.spacing(1),
  },
}));



const Index = () => {
  const classes = useStyles();
  return(
  <div className={classes.floatBtn}>
    <Fab size="small" color="secondary" aria-label="add" className={classes.iconHover}>
          <AddIcon />
        </Fab>
  </div>
)};

Any idea on how to achieve this?


Viewing all articles
Browse latest Browse all 138249

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>