New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-number-variants

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-number-variants

A multi-purpose React number component with variants for numbers, currencies, and percentages

latest
Source
npmnpm
Version
1.2.16
Version published
Weekly downloads
2
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

A multi-purpose React number component with variants for numbers, currencies, and percentages

Features include:

  • format number on-blur; unformat on-focus
  • format based on locale and currency
  • min and max
  • variable number of decimals places
  • show error messages (above or below input)
  • output an event with the input value (on-change or on-blur)

Live demo with examples

https://react-number-variants.netlify.com/

GitHub

https://github.com/MachineLlama/react-number-variants

NPM


https://www.npmjs.com/package/react-number-variants

Usage

npm install react-number-variants --save
or
yarn add react-number-variants

In your React component:

import Number from 'react-number-variants';

Simple example:

<Number
  inputClassName="form-control"
  minNumberOfDecimals={1}
  maxNumberOfDecimals={3}
  onEvent={(event, value) =>
    this.setState({ event, value })
  }
/>

License

Absolutely none; feel free to clone and use any part of this code anywhere you want

Props (all optional)

PropDescriptionTypeDefault
idID of the entire Number component containerstring'react-number-variants'
inputIdID of the input boxstring'number-input'
classNameClassName of the entire Number component containerstring'number-container'
inputClassNameClassName of the input boxstring'number-input'
valueThe default starting value for the inputnumbernull
typeThe type of number rendered; either 'number', 'percent', or 'currency'string'number'
localeThe locale of the number renderedstring'en-US'
currencyIf type is set to 'currency', then this prop will determine the symbol displayedstring'USD'
minThe minimum value the number can benumbernull
maxThe maximum value the number can benumbernull
minNumberOfDecimalsMinimum number of decimal places allowed for valuenumber0 (can't be less than 0)
maxNumberOfDecimalsMaximum number of decimal places allowed for valuenumber20 (can't be greater than 20)
showErrorDetermines whether to show the error message or notbooleanfalse
errorIdID of the error messagestring'error-message'
errorClassNameClassName of the error messagestring'error-message'
errorLocationLocation of the error message. Can be either 'top' or 'bottom', relative to the input boxstring'bottom'
errorMessageThe error message displayedstring'error'
emitOnChangeDetermines whether to emit an event message on-change (can be used for performance or validation purposes)booleantrue
emitOnBlurDetermines whether to emit an event message on-blurbooleantrue
onEventFunction that can be used to get the event name and value from the input. Can be used to drive external events in your React component (like with validation to show the error message)functionnull
disabledDisable inputbooleanfalse
placeholderPlaceholder textstringundefined

Keywords

react

FAQs

Package last updated on 28 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts