New to Material UI and flex I've read a lot of documentation but for some reason I'm missing how to take a Material UI <CancelIcon />
and align right only that icon in a <Drawer />
. I've read that to be able to prevent the <Drawer />
from being inline I need to use flexDirection: 'column'
.
Code
<Drawer
{...{
anchor: 'right',
open: drawerOpen,
onClose: handleDrawerClose,
}}
>
<div className={drawerContainer}>
<CancelIcon className={cancelBtn} />
<GetDrawerChoices />
</div>
</Drawer>
Styles
import { makeStyles } from '@material-ui/core'
const useStyles = makeStyles({
drawerContainer: {
padding: '24px 0',
display: 'flex',
flexDirection: 'column',
},
cancelBtn: {
margin: '0 28px 8px 28px',
cursor: 'pointer',
// justify: 'flex-end',
alignContent: 'flex-end',
},
})
export default useStyles
Research
I've tried the following:
How to add close icon in Material UI Dialog Header top right corner:
cancelBtn: {
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
},
What's the right way to float right or left using the material-ui appbar with material-ui-next?
cancelBtn: {
display: 'flex',
flex: 1,
},
How to align a component to the center/right:
cancelBtn: {
justify: 'flex-end',
},
Further reading: Aligning Items in a Flex Container
Preview
In Material UI with flex how can I get the <CancelIcon />
to align right but leave the remaining text left justified?