Here is a solution for you!
import React from "react";
import { alpha, makeStyles } from "@material-ui/core/styles";
import InputBase from "@material-ui/core/InputBase";
import SearchIcon from "@material-ui/icons/Search";
import CloseIcon from '@material-ui/icons/Close';
import IconButton from '@material-ui/core/IconButton';
import Paper from '@material-ui/core/Paper';
const useStyles = makeStyles((theme) => ({
root: {
padding: '2px 4px',
display: 'flex',
alignItems: 'center',
width: 400,
borderRadius: theme.shape.borderRadius,
backgroundColor: alpha(theme.palette.common.black, 0.15)
},
input: {
marginLeft: theme.spacing(1),
flex: 1,
},
iconButton: {
padding: 10,
}
}));
export default function PrimarySearchAppBar() {
const classes = useStyles();
return (
<Paper component="form" className={classes.root}>
<IconButton type="submit" className={classes.iconButton} aria-label="search">
<SearchIcon />
</IconButton>
<InputBase
className={classes.input}
placeholder="Search..."
inputProps={{ 'aria-label': 'Search...' }}
/>
<IconButton color="primary" className={classes.iconButton} aria-label="directions">
<CloseIcon />
</IconButton>
</Paper>
);
}