import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
import { PercentFormatter } from './percent-formatter.component';

<Meta title="Primitives/PercentFormatter" component={PercentFormatter} />

# PercentFormatter

The percent formatting component uses React International `<FormattedNumber />` under the hood. Passing in a value such as `0.45` will return `45.0%`

It has some defaults in place but these can be overridden. For example, if you want 0 decimal places, you can do:

```jsx
<PercentFormatter
  value={0.456}
  minimumFractionDigits={0}
  maximumFractionDigits={0}
/>
```

Please see the [React International docs](https://formatjs.io/guides/message-syntax/#number-type) for details.

## Normal

<Canvas withToolbar>
  <Story id="primitives-percentformatter--normal" />
</Canvas>

## Round To Whole

<Canvas withToolbar>
  <Story id="primitives-percentformatter--round-to-whole" />
</Canvas>
