Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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: enter image description here

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

like image 272
Hongli Bu Avatar asked Dec 13 '25 02:12

Hongli Bu


1 Answers

You can use material ui progress... see the document. https://material-ui.com/components/progress/#progress

You can also customize it.

like image 175
theWanderer Avatar answered Dec 14 '25 16:12

theWanderer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!