Specify Material UI's Grid item location - javascript

CSS grid layout has the grid-column property to specify grid item location
(e.g. grid-column: 1 / 3)
I want to do the same using Material UI's Grid component, but it doesn't allow me to specify the certain starting and ending points, just the number of columns taken at all.
(e.g.
<Grid container rowSpacing={1}>
<Grid item xs={8}>
Item 1
</Grid>
<Grid item xs={4}>
Item 2
</Grid>
</Grid>
For example, I want the first Item to be located from 2 to 4 column and the second Item to be located from 7 to 10 column. How do I do that in MUI v5?

The Grid component from Material UI has a misleading name. Their Grid component is not based on CSS Grid, It's actually CSS Flexbox with added features. So you wouldn't be able to use it like CSS Grid. You can just use CSS Grid and you won't have any conflicting issues.

Related

MUI V5 Why us Box with Grid component

I'm using MUI to learn some react for the first time. I'm wondering why use the Box component along with the Grid component. From the docs it shows this as an example
export default function BasicGrid() {
return (
<Box sx={{ flexGrow: 1 }}>
<Grid container spacing={2}>
<Grid xs={8}>
<Item>xs=8</Item>
</Grid>
<Grid xs={4}>
<Item>xs=4</Item>
</Grid>
<Grid xs={4}>
<Item>xs=4</Item>
</Grid>
<Grid xs={8}>
<Item>xs=8</Item>
</Grid>
</Grid>
</Box>
);
}
I removed the Box component applying any props to the outermost Grid and everything seems the same, I think. Is there an advantage to wrapping a Grid component with a Box? Any help in would be great!
Removing outer most container seems to do nothing
Box = div
Check it out here: https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Box/Box.js
Which just calls this: https://github.com/mui/material-ui/blob/master/packages/mui-system/src/createBox.js
It's a div that accepts camelCase css props and adhere's to MUI's styling system rules, that's it - it's a div
Almost everywhere you see Box used, replace it with div with the inline CSS props and you'll have the same thing
In your code example, it would only make sense if it were the child of a flex container. Otherwise, it literally does absolutely nothing (that a normal div doesn't), because flex-grow is only relevant inside flex containers.

Textfields in a Grid not responsive when it is under a tab

I have a component under a tab and because of that it makes the Textfield not responsive when it is on a small screen. This is what the Textfield looks like in small screen sizes when I tried checking what it looks like in iphone 5/SE screen size.
How can I make this responsive? I have recreated this in Codesandbox
In your Grid item, add xs={12} to tell the grid item expand to 100% width of its parent, alongside with setting the fullWidth prop of the TextField. See more examples about how you can divide the grid item here.
<Grid item xs={12}>

How can I align the last Material UI item in a flex row to the right?

I am trying to write a React App that has text lined up in a row, and I want the last item to be aligned to the far right. I am using Material UI with a Box API to contain all my elements, with each item being a Typography element.
<Box display="flex" flexDirection="row" alignItems="flex-start">
<Typography align='left' className={classes.currentlyPrinting}>
Currently printing:
</Typography>
<Typography align='left' className={classes.filenameText}>
Filenamjoojpe
</Typography>
<Typography className={classes.completion}>
(3 of 4 completed)
</Typography>
<Box justifyContent="flex-end">
<Typography className={classes.percentage}
style={{display: 'inline-block'}}>30%
</Typography>
</Box>
</Box>
So I tried putting the last Typography element within a box container, and used "justifyConent = flex-end" but it did not work out. The following image shows what I want to happen:
So I want the text that says "30%" to be aligned with the right side of that progress bar I have. The reason for this is that the other three typography elements can have varying characters of text, so I cant just use padding for it. Any ideas?

React Semantic UI : Table.Header Cell is not taking full width

I'm trying to add full width in Semantic React UI, but it's not taking full width.
Code:
<Table.Row>
<Table.HeaderCell style={{Width: '600px'}}>
<Search/>
</Table.HeaderCell>
</Table.Row>
Use props name 'colSpan' to defined number of who column
<Table.HeaderCell colSpan={8}>
<Search/>
</Table.HeaderCell>
Looks like you aren't modifying the first header cell for that column (which is actually Company Name, not search).
Here is an example on how to properly modify column widths in a table
https://codesandbox.io/s/5v800vplmk?module=/example.js
If your intent is to not make the search bar part of the table column structure, then you probably don't want to put it in a row / cell.

How to set lebel right allinged in columlayout

I am very new in react js and using matrial core UI. Here what i found is whenever i am using columnlayout with some xs value then the component inside the column is left allinged.
For bringing it right i need to increase xs which is not fitting correct. Is there any way I can place my tag element inside column layout to right allinged. Any css heck ?
My Code
<Columnlayout xs{1} item>
<InputLabel>Some Text</InputLabel>
</Columnlayout>
You can use the api helper of Material-ui
<Columnlayout xs{1} item justify="flex-end">
<InputLabel>Some Text</InputLabel>
</Columnlayout>
Here is a link for all the customization
https://material-ui.com/api/grid/

Categories

Resources