Want to Create Pagination on table from Material UI in React Application - reactjs

I am creating a table with data. Want pagination like this attached image in the footer.
Left-hand side I want the numbers and right-hand side Results per page.

Probably you have to use the combination of Pagination and Table pagination. And hide the unused panels with the CSS.
<div className={classes.root}>
<Pagination count={10} variant="outlined" shape="rounded" />
<TablePagination
component="div"
count={100}
page={page}
onChangePage={handleChangePage}
rowsPerPage={rowsPerPage}
onChangeRowsPerPage={handleChangeRowsPerPage}
/>
</div>;
I have created a sample codesandbox (This is just a workaround) - https://codesandbox.io/s/material-demo-forked-wmm4z?file=/demo.tsx:891-1225
Let me know if you need more help.

As #Tejogol mentioned you can use the Material UI table example pagination and change it.
You can store the current page number in a state variable and add a different style to the corresponding navigation field. The style seems like a simple border with a small border radius (1-3px).
For the results per page you can use React spacers. Don't forget to update the current page number when changing the results per page.

Related

React MUI - is it possible to place a component / div (a chart for example) inside a Table Cell?

I'm using React MUI, and I'd like to place a component (a chart for example) inside a Table Cell.
Is it possible?
Yes you can place any node in MUI Table cell like this:
<TableCell>
<div>
...
</div>
</TableCell>
I didn't try with charts, but I was able to place barcode, so it should be matter of adjusting and styling.

Is there a way to make ant design pagination rows per page always show up?

I am currently using ant design in my reactJs application and I notice that Pagination rowsPerPage drop-down only appear when totalElement is greater than the maximum option in rowsPerPage. Is there a way I can make rowsPerPage always visible?
Thanks in advance
By default, it only show dropdown (Actually it is called sizeChanger Dropdown) when total > 50.
If you want to show sizeChanger dropdown manually, you can pass showSizeChanger: true as prop in pagination component.
<Pagination showQuickJumper total={...} />
Please check Antd Pagination API for all the options you can pass to pagination component. Antd Pagination API
TLDR
If you want to override the dropdown pageSize, you can pass your custom values in pageSizeOptions:
<Pagination showQuickJumper total={...}. pageSizeOptions: [15, 20, 30, 40, 50] />

How to control ReactJS MUI table column height and width

Recently I used ReactJS MUI Table component, but I feel it's height is too large for my project nature. I am unable to properly control cell width and height of MUI Table component. Please anyone help me.
There are a few ways to customize your tables in Material UI. This page goes over the recommended ways in detail.
For tables you can add size='small' to your <TableCell> components make your table cells smaller. Or to make the table extremely dense, you can add padding='none' to your <TableCell> components.
<TableCell size='small'>
More specifics about Material UI Tables can be found here.

How to create a rating bar(Or linear gauge) using material UI (React)

I am new to React, I want to create a rating bar like this:
I want to use material UI, but I didn't find a component like this.
I found a rating UI component: https://material-ui.com/components/rating/. but I need the UI to be like a linear gauge and change color with a different number (1/5, 2/5,3/5,4/5,5/5).
Actually, I already used the rating component:
<Grid item xs={6} className={classes.overAllScoreValueContainer}>
<Box component="fieldset" marginLeft={0} marginTop={0.25} padding={0} borderColor="transparent">
<Rating
name="overall-score"
value={this.state.overAllRating}
readOnly
size={"large"}
classes={{
iconFilled: this.props.classes.iconFilled,
iconHover: this.props.classes.iconHover
}}
/>
</Box>
</Grid>
but the UI is not correct.
anyone can help?
Thank you for pointing out using the progress bar in material UI.
I can make the shape like what shown in the picture, but how to change color according to the value??
please check this:
https://codesandbox.io/s/charming-water-cx6dd?file=/demo.js
You can use material ui progress... see the document.
https://material-ui.com/components/progress/#progress
You can also customize it.
Hey thanks for posting your sandbox. I was able to provide the color dynamically with your help. If you're still stuck here then just pass the color as a prop and !important to your style. Thank you soo much.
Here's the updated sandbox link - https://codesandbox.io/s/staging-bird-dh50kl

how to achieve multi line label with react Material UI

I am using react js to develop my web application and I am using React material design for the UI. Below is the url which I am referring.
https://material-ui-next.com/
I am trying to achieve something like this
I am using the tabs but I can't get a two line text as like the image I shared. either I can use image and label or if the label is too big then it goes in multi line. How can I achieve two line text as like the image
In order to make multiline text, you can insert the HTML < pre > tag, from which the text formatting is retained. Then it remains to inherit the style of the text.
<Typography>
<pre style={{ fontFamily: 'inherit' }}>
{content}
</pre>
</Typography>
It's an old question, but I see nobody has answered it yet.
In order to get multi line and multi styles for your tab label, you need to place your labels and values in two different items. (make sure you wrap them in a div first)
The preferred way in MUI #1.0.0 is to use the <Typography /> tag.
Check out the typography docs for all the variants.
So it would look something like this:
<Tab
value={this.state.value}
label={
<div>
<Typography variant="caption">
Following
</Typography>
<Typography variant="title">
58
</Typography>
</div>
}
/>
However since all your tabs need that, you should probably create a function to take care of that.
I have created a sandbox based on the MUI example provided here: https://codesandbox.io/s/vw6107rv3

Resources