Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
react-pretty-numbers
Advanced tools
A react component to display numeric data, in it's various formats. These may include currencies, percentages and large numbers.
A React component to display numeric data in various formats. This may include currencies, percentages and large numbers.
e.g. it can output number 25300
as 25.3k
A minimal usage will just display the numeric value
let myNumber = 123456;
<NumericLabel>{myNumber}</NumericLabel>;
Other options can be passed in as params
like so:
let params = {
justification: 'L',
locales : 'en-AU'
currency: true,
currencyIndicator: 'USD$',
percentage: false,
precision: 2,
commafy: false,
shortFormat: true,
title: true,
cssClass: ['class1', 'class2']
};
<NumericLabel params=params>123</NumericLabel>;
Value | Description | Default |
---|---|---|
L | Left justified | |
R | Right justified | * |
C | Centered |
Default to 'en-AU'
Value | Description |
---|---|
true | to include text dollar sign |
and 2 decimals eg: 'usd $0.00' | |
false | to have no format eg: '0.00' |
if the currency:
parameter is set to true
and no value is supplied here, default to a dollar sign $
Value | Description |
---|---|
true | to have 2 decimals and |
include a percentage sign | |
eg: '00.00%' | |
false | not format eg: '0.00' |
Value | Description |
---|---|
Integer x | to round to x decimal places |
nil | no rounding |
Value | Description |
---|---|
ceil | to round up to the nearest whole number |
floor | to round down to the nearest whole number |
nil | no ceil or floor |
Value | Description |
---|---|
true | Commas will be include, eg: 10,000 |
false | Commas will not be include, eg: 10000 |
Value | Description |
---|---|
true | Short format will be applied, eg: 10k |
false | Short format will not be applied, eg: 10000 |
shortFormatMinValue
Value | Description |
---|---|
100000 | Short format will be applied if the number is higher or equal to 100000 |
Value | Description |
---|---|
Integer x | shortend numbers to round to x decimal places |
nil | no rounding |
Value | Description |
---|---|
false | Title will not appear |
true | Title will appear and show unformatted number, eg: 123456.789 |
string | Title will appear and show the value of this option, eg: Some string |
import React,{Component} from 'react';
import ReactDOM from 'react-dom';
import NumericLabel from 'react-pretty-numbers';
class App extends Component {
constructor(props){
super(props);
}
render() {
var option = {
'justification':'C',
'locales':'en-AU',
'currency':true,
'currencyIndicator':'AUD',
'percentage':false,
'precision':2,
'wholenumber':null,
'commafy':true,
'shortFormat':true,
'shortFormatMinValue': 100000,
'shortFormatPrecision': 1,
'title':true,
'cssClass':['red']
};
return(
<div className='numeric-wrapper'>
<h2>Numeric Label Component</h2>
<NumericLabel params={option}>1243.2155</NumericLabel>
<NumericLabel>123</NumericLabel>
</div>
);
}
}
ReactDOM.render(<App />,document.querySelector('.container'));
Clone the repo as a new project:
git clone https://github.com/pvoznyuk/react-pretty-numbers.git <numeric-label>
Start Server:
First you have to replace the lib/component/numeric_label.js to server.js in package.json
cd numeric-label
npm i
npm start
Run App:
npm start command automatically initiate browser at 3000 port
http:://localhost:3000
Run tests:
cd numeric-label
npm i
npm test
Make sure you configure your editor/IDE to use:
.editorconfig
.eslintrc
FAQs
A react component to display numeric data, in it's various formats. These may include currencies, percentages and large numbers.
The npm package react-pretty-numbers receives a total of 843 weekly downloads. As such, react-pretty-numbers popularity was classified as not popular.
We found that react-pretty-numbers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.