react-number-shortner
v1.0.3
Published
A React component that takes a number as a prop and converts it to a short format with a suffix of K, M, or B depending on the number , Eg 12324 => "12.3k" , 87132435 "87.1M".
Downloads
2
Maintainers
Readme
react-number-shortner
react-number-shortner
is a React package that converts numbers into a formatted string with the appropriate symbol (k, m, b) based on the magnitude of the number.
Installation
npm install react-number-shortner
Usage
To use the package in your project, import the NumberShortener
function from the package:
import React from "react";
import NumberShortener from "react-number-shortner";
function App() {
return (
<div>
<NumberShortener number={12345} /> // Output: 12.3k
</div>
);
}
export default App;
API
The NumberShortener
function takes a single argument - the number to be formatted - and returns a string with the formatted number.
numberFormat(number: number): string;