Move Refer a friend and name button to right

Viewed 47

I need to move two button two right all the way right.

const getDisplayName = () => {
        if (authContext.user.first_name) {
            return `${authContext.user.first_name} ${authContext.user.last_name}`;
        }
        return authContext.user.email;
    };
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', width: '100%', margin: '0'}}>
                    <ReferralModal />
                    <div>
                        <Button aria-controls='simple-menu' aria-haspopup='true' onClick={handleClick}>
                        /> */}
                            {getDisplayName()}
                        </Button>
                </div>
                    <Menu
                        id='account-menu'
                        anchorEl={anchorEl}
                        keepMounted
                        open={Boolean(anchorEl)}
                        onClose={handleClose}
                        anchorOrigin={{
                            vertical: 'bottom',
                            horizontal: 'right',
                        }}
                        transformOrigin={{
                            vertical: 'top',
                            horizontal: 'right',
                        }}
                    >
                        <MenuItemLink
                            to={`${config.basePath}/account-settings`}
                            primary='Settings'
                            icon={<SettingsIcon />}
                            onClick={handleClose}
                        />
                        <MenuItemLink primary='Logout' icon={<ExitToAppIcon />} onClick={logout} />
                    </Menu>
                </div>

I need to move two buttons to the right.

enter image description here

1 Answers

You are centering the elements/components on the major axis (i.e. the row direction). If you want to justify them to the right (i.e. the end) then specify justify-content: 'flex-end'; CSS rule.

justify-content values

<div
  style={{
    display: "flex",
    justifyContent: "flex-end",
    alignItems: "center",
    width: "100%",
    margin: "0"
  }}
>
  ...
</div>
Related