Skip to content

Properties

PropertyTypeDescription
asNumberboolean(optional) Set to true to automatically set a number mask based on the given or inherited locale.
asPercentboolean(optional) Set to true to automatically set a number mask with a percentage sign based on the given or inherited locale.
asCurrencyboolean
string
(optional) Set to true to use NOK or give it a currency code e.g. USD to automatically set a currency mask based on the given or inherited locale.
maskOptionsobject(optional) Use it to manipulate internal masks. You can use it instead of e.g. numberMask or currencyMask. All options are listed below.
numberMaskboolean
object
(optional) Set to true to enable the default numbers formatting – or give an object containing the number mask properties. More details below. Can be a JSON string as well, containing the number mask properties. Is disabled by default.
currencyMaskboolean
object
(optional) Set to true or set the valuta (currencyMask="kr") to enable a custom currency mask – or give an object containing the number mask properties. More details below. Can be a JSON string as well, containing the number mask properties. Is disabled by default. Defaults to kr.
numberFormatobject(optional) Use an object with NumberFormat.
localestring(optional) Define the locale to be used in the asNumber or asCurrency masked. It will be inherited from the Eufemia Provider if not given. Defaults to nb-NO.
maskRegExp
Array<RegExp | string>
(optional) A mask defined as an array of RegExp and string tokens (e.g. [/\d/, /\d/, " ", /\d/, /\d/]) or a single RegExp. Defaults to number mask.
allowOverflowboolean(optional) Allow users to keep typing after the defined mask has been filled. Extra characters will be appended without masking.
overwriteModestring
function
(optional) Control how overwriting characters is handled; shift (default) moves to the next slot while replace stays on the current slot.
showMaskboolean(optional) Show mask when input is empty and has no focus. Defaults to false.
Spacestring
object
(optional) Spacing properties like top or bottom are supported.
InputVarious(optional) All Input properties are supported.

Number mask properties

The number mask is used for all kinds of number based masks, like:

Locale based masks:

  • asNumber
  • asCurrency
  • asPercent

Static masks:

  • numberMask
  • currencyMask

You can maskOptions to manipulate the options.

Defaults to Norwegian number format.

PropertyTypeDescription
prefixstring(optional) What to display before the amount. Defaults to an empty string.
suffixstring(optional) What to display after the amount. Defaults to an empty string.
thousandsSeparatorSymbolstring(optional) Character with which to separate thousands. Defaults to ' '.
allowDecimalboolean(optional) Whether or not to allow the user to enter a fraction with the amount. Defaults to false.
decimalSymbolstring(optional) Character that will act as a decimal point. Defaults to ','.
decimalLimitnumber(optional) How many digits to allow after the decimal. Defaults to 2.
integerLimitnumber(optional) Limit the length of the integer number. Defaults to null for unlimited.
allowNegativeboolean(optional) Whether or not to allow negative numbers. Defaults to true.
disallowLeadingZeroesboolean(optional) Whether or not to allow leading zeroes during typing. A leading zero is any 0 digit that comes before the first nonzero digit in a number string in positional notation - wikipedia. Defaults to false.

Custom number mask usage

The number mask is included and can be set with the numberMask property.

// 1. Use the desired configurations
const numberMask = {
prefix: '',
suffix: ',- kr'
}
// 2. Then pass 'numberMask' to the InputMasked component as the numberMask
<InputMasked numberMask={numberMask} ... />