0

I have a reactjs code which calculates some cost value and shows them on some accordion rows as shown here:

enter image description here

the code for showing this is something like:

const useStyles = makeStyles((theme) => ({
    root: {
        width: '100%',        
    },
    .......

    headerItem: {
        padding: '0 5px',
        color: '#333'
    },
}));

<Typography className={classes.headerTitleTxt} variant="subtitle1">% Cost: </Typography>
                                        <NumberFormat
                                            className={classes.headerItem}
                                            value={props.prjData.cost}
                                            suffix={'%'}
                                            type="text"
                                            thousandSeparator={','}
                                            displayType="text"
                                            decimalScale={2}
                                        />

How can I change this code to align the numbers to right. I mean how can I print the numbers here such that they line up, such as:

    % Cost:   4.43% 
    % Cost:   7.09% 
    % Cost:  43.18% 

Thanks in advance

1 Answer 1

1

You can do that easily with flexbox. Example: https://codesandbox.io/s/material-demo-forked-p9f30?file=/demo.js

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.