Cannot get a box to fully right align within an AppBar - css

I have this MUI App bar which contains an image, some text, and a box containing an Icon along with some info on the logged in user. I am having difficulty forcing the box with user info to be right aligned. I cannot get it to go to the right edge of the page. I can only get it to stick to the end of the last Box.
<AppBar position="fixed" className={classes.appBar}>
<Toolbar>
<div id="app-bar-box" style={{ width: "100%", display: "flex" }}>
<Box id="logo-env-txt-box" justifyContent="left" style={{ display: "flex", alignItems: "center" }}>
<a href="/home">
<SVGLOGO className="logo_stack" />
<SVGLOGOHORI className="logo" />
</a>
<Typography className={classes.envFlag} hidden={hidden}>
You are on the {process.env.REACT_APP_ENVIRONMENT} environment. Click{" "}
here to go to production.
</Typography>
</Box>
<Box id="user-info-box" justifyContent="right" style={{ display: "flex", alignItems: "center", width: "400px", height: "64px" }}>
<i class="dds__icon dds__icon--user" style={{ fontSize: "24px", color: "#636363", marginRight: "10px" }}></i>
<Box style={{ marginLeft: "10px" }}>
<Typography style={{ color: "#636363", fontWeight: 400, fontSize: 14 }}>
John Doe Admin
</Typography>
<Typography style={{ color: "#636363", fontWeight: 400, fontSize: 14 }}>
Product Lead
</Typography>
</Box>
</Box>
</div>
</Toolbar>
</AppBar>

(Repost)
No need to use width for your div user-info-box.
You can use justifyContent : "space-between" for your first element and you can remove both justifyContent : "left" and justifyContent : "right" of your children elements.
<AppBar position="fixed" className={classes.appBar}>
<Toolbar>
<div id="app-bar-box" style={{ width: "100%", display: "flex", justifyContent: "space-between" }}>
<Box id="logo-env-txt-box" style={{ display: "flex", alignItems: "center" }}>
<a href="/home">
<SVGLOGO className="logo_stack" />
<SVGLOGOHORI className="logo" />
</a>
<Typography className={classes.envFlag} hidden={hidden}>
You are on the {process.env.REACT_APP_ENVIRONMENT} environment. Click{" "}
here to go to production.
</Typography>
</Box>
<Box id="user-info-box" style={{ display: "flex", alignItems: "center", height: "auto" }}>
<i class="dds__icon dds__icon--user" style={{ fontSize: "24px", color: "#636363", marginRight: "10px" }}></i>
<Box style={{ marginLeft: "10px" }}>
<Typography style={{ color: "#636363", fontWeight: 400, fontSize: 14 }}>
John Doe Admin
</Typography>
<Typography style={{ color: "#636363", fontWeight: 400, fontSize: 14 }}>
Product Lead
</Typography>
</Box>
</Box>
</div>
</Toolbar>
</AppBar>

Related

How can I make all the elements inside the page without being cut in any screen resolution?

I have three elements on my page, which are pictures, Card(containing picture and several typography), a Button. The direction is column.
The problem is the pictures and the button will be cut due to the screen resolution. How can I make those three elements inside the page without being cut?
This is what I expect:
The problem, the pictures and the button will be cut.
Here is my code:
<Box
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
width: "100%",
height: "100%",
overflow: 'auto',
}}
>
<Grid
container
direction="column"
alignItems="center"
>
<Grid item>
<CardMedia
component="img"
image="logo.png"
alt="logo"
sx={{
width: { xs: '80%', sm: '100%', md: '100%', lg: '100%', xl: '100%' }
}}
style={{ margin: '0 auto' }}
/>
</Grid>
</Grid>
<Grid container direction="row" justifyContent="center">
<Grid item xs={9} sm={8.6} md={6} lg={5} xl={4}>
<Card
sx={{
backgroundColor: 'white',
borderRadius: '4px'
}}
>
<Box
sx={{mt:4, mb:4, mx:4}}
>
<Box>
<Stack
direction={{xs: "column", sm: "row"}}
alignItems={{xs: "center", sm: "flex-start"}}
justifyContent={{xs: "center", sm: "flex-start"}}
spacing={{ xs: 0, sm: 3}}
>
<CardMedia
component="img"
sx={{ width: {xs: 120, sm: 160}, height: {xs: 120, sm: 160} }}
image="image.png"
alt="image"
style={{borderRadius: "6px"}}
/>
<Box
sx={{wordWrap: "break-word", overflow: "hidden"}}
>
<Typography>
.....
</Typography>
<Typography>
.....
</Typography>
</Box>
</Stack>
</Box>
</Box>
<Box
sx={{mx:4, mb: 10, wordWrap: "break-word", overflow: "hidden"}}
>
<Box>
<Typography>
.....
</Typography>
<Typography>
.....
</Typography>
</Box>
<Box
sx={{mt:2}}
>
<Typography>
.....
</Typography>
<Typography>
.....
</Typography>
</Box>
</Box>
</Card>
</Grid>
</Grid>
<Grid container direction="row" justifyContent="center">
<Grid item xs={9} sm={8.6} md={6} lg={5} xl={4}>
<Button
onClick={() => setStep(2)}
>
Next
</Button>
</Grid>
</Grid>
</Box>
Try to add some padding to container element.

Make all rows the same height MUI grid

<Grid container spacing={2}>
<Grid item xs={12} md={4} lg={3}>
<Card>
<CardActionArea>
<CardMedia
width={1}
alt="Meal Products POS"
sx={{ maxWidth: 400 }}
component="img"
image={themesObj.pos.featuredProduct}
/>
<CardContent sx={{ textAlign: 'center' }}>
<Typography variant="h6" sx={{ fontWeight: 'bold' }}>
Meal Products POS
</Typography>
</CardContent>
</CardActionArea>
</Card>
</Grid>
<Grid item xs={12} md={4} lg={3}>
<Card>
<CardActionArea>
<CardMedia
width={1}
alt="Barcode normal products POS"
sx={{ maxWidth: 400 }}
component="img"
image={themesObj.pos.normalProduct}
/>
<CardContent sx={{ textAlign: 'center' }}>
<Typography variant="h6" sx={{ fontWeight: 'bold' }}>
Barcode normal products POS
</Typography>
</CardContent>
</CardActionArea>
</Card>
</Grid>
<Grid item xs={12} md={4} lg={3}>
<Card>
<CardActionArea>
<CardContent sx={{ textAlign: 'center' }}>
<NotInterestedIcon sx={{ fontSize: 200 }} />
<Typography variant="h6" sx={{ fontWeight: 'bold' }}>
Return a product
</Typography>
</CardContent>
</CardActionArea>
</Card>
</Grid>
</Grid>
I have this grid component, and it displays the following:
It is depending on the image height, it makes the card height.
I want to make the height the same for all the cards, dynamically. but how?
I am using the newest version of MUI as of now (v5.10.3).
what to do?

Override react mui select dropdown style

I'm using the react mui Select Component for forms and now for language select
my problem is for the language Select I need a different style for the dropdown I can do it by overriding the relevant class but the problem is it will happen to every Select and I want it only for the language Select as you can see in the photo:
and here my code:
const LanguagesSelect = props => {
return (
<Select className="test" classes="assad" style={{ position: "relative !important", left: "20px !important", top: "30px !important", width: "168.3px !important", background: "white !important", borderRadius:"12.75px" }} >
<MenuItem className="menuTest" style={{ paddingLeft: "5px" }}>
<div style={{ display: "flex", width: "100%" }}>
<img src={require("../../../assets/img/icons/flags/franch.svg").default} />
<div style={{ marginLeft: "5px" }} >Franch</div>
</div>
</MenuItem>
<MenuItem className="menuTest" style={{ paddingLeft: "5px" }}>
<img src={require("../../../assets/img/icons/flags/eng.svg").default} />
<div style={{ marginLeft: "5px" }}>English</div>
</MenuItem>
<MenuItem className="menuTest" style={{ paddingLeft: "5px" }}>
<img src={require("../../../assets/img/icons/flags/turkish.svg").default} />
<div style={{ marginLeft: "5px" }}>Turkish</div>
</MenuItem>
<MenuItem className="menuTest" style={{ paddingLeft: "5px" }}>
<img src={require("../../../assets/img/icons/flags/czech.svg").default} />
<div style={{ marginLeft: "5px" }}>Czech</div>
</MenuItem>
<MenuItem className="menuTest" style={{ paddingLeft: "5px" }}>
<img src={require("../../../assets/img/icons/flags/hebrew.svg").default} />
<div style={{ marginLeft: "5px" }}>עברית</div>
</MenuItem>
</Select>
)
}
You can use the sx prop to override the default style.
here's a link for more description mui_sx_prop
You can give external css to the Select element and manipulate the child (MenuItem) from there.

Align not center when resize for mobile screen

Please help anyone,
3d design Icon size is 219px
When I use the first Div component size 219px is working fine as well as all Cols are attached together in full screen and align center to the mobile screen also
and if I try to use it as the same Div style using Card's content is not able to align properly..... is there any issue with Card component or I missed something somewhere
<div style={{ paddingTop: 50, justifyContent: "center", alignItems: "center", display: "flex", backgroundColor: "red" }}>
<Row>
<Col style={{ width: 219 }}> <Example /></Col>
<Col style={{ width: 219 }}><Example1 /> </Col>
<Col style={{ width: 219 }}><Example1 /></Col>
<Col style={{ width: 219 }}><Example1 /></Col>
<Col style={{ width: 219 }}><Example1 /></Col>
</Row>
</div>
<div style={{ paddingTop: 10, justifyContent: "center", alignItems: "center", display: "flex", backgroundColor: "red" , textAlign:"left"}}>
<Row>
<Col style={{ width: 219 }}>
<Card style={{ width: 219 }}>
<Card.Img variant="top" src={threedcard} />
<Card.Header style={{ textAlign: "center", backgroundColor: "#e0741b", color: "white" }}> 3D DESIGN</Card.Header>
<Card.Body style={{ backgroundColor: "#fff567" }}>
<Card.Text>
We at Hephy, have the finest Designer to make 3d models out of your desired material.
</Card.Text>
<Threed />
</Card.Body>
</Card>
</Col>
<Col style={{ width: 219 }}>
<Card style={{ width: 219 }}>
<Card.Img variant="top" src={eventcard} />
<Card.Header style={{ textAlign: "center", backgroundColor: "#d15950", color: "white" }}> EVENT </Card.Header>
<Card.Body style={{ backgroundColor: "#feece6" }}>
<Card.Text>
Right from employee birthday parties to culture events, we like to add that something extra to the Event to make it grand.
</Card.Text>
<Eventmodal />
</Card.Body>
</Card>
</Col>
<Col style={{ width: 219 }}>
<Card style={{ width: 219 }}>
<Card.Img variant="top" src={decocard} />
<Card.Header style={{ textAlign: "center", backgroundColor: "#dc6372", color: "white" }}>DECORATION</Card.Header>
<Card.Body style={{ backgroundColor: "#fff0f5" }}>
<Card.Text>
At hephy, we understand the emotions of parents and their joy when their Children get married.
</Card.Text>
<Decoration />
</Card.Body>
</Card>
</Col>
<Col style={{ width: 219 }}>
<Card style={{ width: 219 }}>
<Card.Img variant="top" src={promoaddcard} />
<Card.Header style={{ textAlign: "center", backgroundColor: "#31986b", color: "white" }}>PROMO & ADDS</Card.Header>
<Card.Body style={{ backgroundColor: "#b7fbf3" }}>
<Card.Text>
Rather focusing on specific product or services, we focus on your brand as a whole. It enables to increase your growth in many ways.
</Card.Text>
<Promomodal />
</Card.Body>
</Card>
</Col>
<Col style={{ width: 219 }}>
<Card style={{ width: 219 }}>
<Card.Img variant="top" src={festcard} />
<Card.Header style={{ textAlign: "center", backgroundColor: "#3d7867", color: "white" }}>FEST</Card.Header>
<Card.Body style={{ backgroundColor: "#cff6f2" }}>
<Card.Text>
We provide School and College Events. While organizing events, we provide proper arrangements for everything.
</Card.Text>
<Festmodal />
</Card.Body>
</Card>
</Col>
</Row>
</div>
do justify-space-around in parent div

Flex not making item responsive

I am using highcharts inside Flex to make it responsive across all screen sizes but its not becoming responsive for mobile screens. Below is my code in reactJs and issue is replicated at
https://codesandbox.io/s/highcharts-react-demo-s31oo
<div>
<Box display="flex" flexWrap="wrap" flexDirection="row">
<Box m={0.5} style={{ flexBasis: "48%", minWidth: '0' }}>
<LineChart
chartData={ChartData}
/>
</Box>
<Box m={0.5} style={{ flexBasis: "48%", minWidth: '0' }}>
<LineChart
chartData={ChartData2}
/>
</Box>
</Box>
</div>
What's wrong in my design?
can you use flexGrow: 1
<div>
<Box display="flex" flexWrap="wrap" flexDirection="row">
<Box m={0.5} style={{ flexBasis: "48%", minWidth: "0", flexGrow: 1 }}>
<Chart chartData={options} />
</Box>
<Box m={0.5} style={{ flexBasis: "48%", minWidth: "0", flexGrow: 1 }}>
<Chart chartData={options} />
</Box>
</Box>
</div>

Resources