Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MenuItem icons are not lined up, can not use flex to move icon #43519

Closed
29er opened this issue Aug 29, 2024 · 1 comment
Closed

MenuItem icons are not lined up, can not use flex to move icon #43519

29er opened this issue Aug 29, 2024 · 1 comment
Labels
component: menu This is the name of the generic UI component, not the React module! customization: css Design CSS customizability package: material-ui Specific to @mui/material

Comments

@29er
Copy link

29er commented Aug 29, 2024

Steps to reproduce

I am unable to get these icons to align right( flex-end)

Steps:

                <MenuItem onClick={() => updateRankings(selectedOption!, 2)}>
                    <Typography variant="body2" color="text.secondary">
                        {getRankLabel(2)}
                    </Typography>

                    <StarHalf style={{ color: 'rgba(255, 168, 0, 1)' }}/>
                </MenuItem>
                <MenuItem onClick={() => updateRankings(selectedOption!, 3)}>
                    
                    <Typography variant="body2" color="text.secondary">
                       {getRankLabel(3)}
                    </Typography>
                        <StarBorderOutlined style={{ color: 'rgba(255, 168, 0, 1)', alignSelf: 'flex-end' }} />
                       
                </MenuItem>

Current behavior

Screenshot 2024-08-29 at 11 09 19 AM

Expected behavior

Screenshot 2024-08-29 at 11 07 29 AM

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: mui icons , cant align

@29er 29er added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 29, 2024
@siriwatknp
Copy link
Member

siriwatknp commented Aug 30, 2024

The MenuItem is a flexbox, there are several options:

  1. add flex: 1 to the Typography to stretch the text: <Typography sx={{ flex: 1 }}>
  2. add margin left: "auto" to the Star: <Star sx={{ ml: 'auto' }}>
  3. follow the demo https://mui.com/material-ui/react-menu/#icon-menu

@siriwatknp siriwatknp added component: menu This is the name of the generic UI component, not the React module! customization: css Design CSS customizability package: material-ui Specific to @mui/material and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: menu This is the name of the generic UI component, not the React module! customization: css Design CSS customizability package: material-ui Specific to @mui/material
Projects
None yet
Development

No branches or pull requests

2 participants