Overwrite mode

Overwrite mode regulates behaviour of the mask when user inserts a new character somewhere in the middle of text field, overwriting the character at the current index.

overwriteMode can be of a following type:

  • shift (default)
  • replace
  • function that receives element state as an argument and returns shift or replace

Shift mode

The classic mode that everyone is used to. Inserting a new character in the middle of the text field value shifts all following characters to the right.

    
    
    
    
    
    
    
    
    
    

Replace mode

All new inserted characters replace the old characters at the same position. No character shifts. The length of the value remains the same after inserting new character somewhere in middle of the text field.

    
    
    
    
    
    
    
    
    
    

Dynamically detected mode

Parameter overwriteMode also accepts function that will called before each insertion of new characters. This function has one argument — current element state (read more about it in the "Element state" section). And this function should return one of two possible values: shift or replace .

    
    
    
    
    
    
    
    
    
    

Next steps

The following sections are recommended to explore core concepts further: