1

I'm trying to add Thousand separator to my mui-textField value,knowing that i already made digit separation.my code looks like this:

<TextField
                    size='small'
                    label='Total Cotisations Encaissées'
                    value={
                        totalEncaissement
                         ?.toFixed(modeMO)
                        ?.replace(/\d(?=(\d{3})+\.)/g, "$& ") || 0
                    }
                    variant='outlined'
                    fullWidth
                    type={"number"}
                />
            </Grid>

The field doesn't dispay anything when i add replace, but works totally fine with toFixed only. Please could somebody help

Aymen LMIR
  • 81
  • 3
  • 11

1 Answers1

4

According to MUI documentation you can use react-number-format package to add a thousand separators to the TextField component.