@hixme-ui/percentage

2.1.0 • Public • Published

Percentage

npm i --save @hixme-ui/percentage

View it live

Props

Name Type Default
hideDecimals bool false
value number null

Basic Usage

Percentage can use a child value or a value prop for the number, and handles decimal placement and rounding.

import Input from '@hixme-ui/percentage'

<Percentage value='0.314' />
<Percentage>0.314</Percentage>
// both output 31.40%

hideDecimals

<Percentage hideDecimals value='0.891342' />
// outputs 89%

Format

Percentage has a static format function if needed outside of a JSX context.

Percentage.format({
  value: 0.1234
})
// outputs 12.34%

Percentage.format({
  value: 0.1234,
  hideDecimals: true,
})
// outputs 12%

Package Sidebar

Install

npm i @hixme-ui/percentage

Weekly Downloads

8

Version

2.1.0

License

MIT

Unpacked Size

10.8 kB

Total Files

9

Last publish

Collaborators

  • sureco-devops
  • sureco-engineering
  • dreamingbinary
  • billyxs