Search code examples
number-formattingmudblazor

MudBlazor MudNumercField with thousand separator


Can I set Format parameter somehow to display the number with thousand separatot in MudNumericField, please. I tried to set it to "n" but it didn't work. For example: 151 342


Solution

  • You can add C# custom numeric format strings to MudNumericField.Format property.

    e.g.

    For your input of 151342 and expected output of 151 342 You can use "### ###" or "000 000"

    "0" Replaces the zero with the corresponding digit if one is present; otherwise, zero appears in the result string.

    "#" Replaces the "#" symbol with the corresponding digit if one is present; otherwise, no digit appears in the result string.

    <MudNumericField Format="### ###" T="int" @bind-Value="_myValue"/>
    <MudNumericField Format="000 000" T="int" @bind-Value="_myValue"/>
    
    @code {
        public int _myValue = 151342;
    }
    

    👉 MudBlazor Snippet