Skip to content

A simple ultra lightweight VanillaJS Webcomponent to display numbers including currencies

License

Notifications You must be signed in to change notification settings

toarm/number-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

number-format-(webcomponent)

A simple ultra lightweight VanillaJS Webcomponent to display numbers including currencies.

  • No dependencies
  • 1.87 kb Source Code
  • 800 Bytes zipped

Installation

npm i -S number-format-webcomponent

Usage

Include number-format.js:

    <head>
      <!-- if you want to support legacy browser add the webcomponents-loader -->
      <!-- <script src="node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> -->
      <script type="module" src="node_modules/number-format-webcomponent/number-format.js"></script>
      ...
      
    <body>
      <number-format number="5.2136"></number-format>

See the demo.html for the results.

Default - Browser Locale

<number-format number="5.2136"></number-format>

Result depends on your Browser Locale. Please see demo.html

British Currency Style

<number-format number="5.2136" locale="en-GB" currency="GBP"></number-format>

£5.21

German Style - Using ,

<number-format number="5.2136" locale="de-DE"></number-format>

5,21

German Currency Style

<number-format number="5.2136" locale="de-DE" currency="EUR"></number-format>

5,21 €

4 Digits

<number-format number="5.2136" min-digits="4" max-digits="4"></number-format>

Result depends on your Browser Locale. Please see demo.html

About

A simple ultra lightweight VanillaJS Webcomponent to display numbers including currencies

Resources

License

Stars

Watchers

Forks

Packages

No packages published