Skip to content

Commit

Permalink
Fix typo in NumberField documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto authored Mar 24, 2021
1 parent 3e48fa5 commit 4c62d18
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions docs/Fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,16 +463,16 @@ import { NumberField } from 'react-admin';

| Prop | Required | Type | Default | Description |
| --------- | -------- | ------ | ------- | -------------------------------------------------------------------------------------------------------- |
| `locales` | Optional | string | '' | Override the browser locale in the date formatting. Passed as first argument to `Intl.DateTimeFormat()`. |
| `locales` | Optional | string | '' | Override the browser locale in the date formatting. Passed as first argument to `Intl.NumberFormat()`. |
| `options` | Optional | Object | - | Number formatting options. Passed as second argument to `Intl.NumberFormat()`. |

`<NumberField>` also accepts the [common field props](./Fields.md#common-field-props).

#### Usage

`<NumberField>` uses `Intl.NumberFormat()` if available, passing the `locales` and `options` props as arguments. This allows a perfect display of decimals, currencies, percentages, etc.
`<NumberField>` uses `Intl.NumberFormat()` if available, passing the `locales` and `options` props as arguments. This allows a perfect display of decimals, currencies, percentages, etc. See [Intl.NumberFormat documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat) for the `options` prop syntax.

If Intl is not available, it outputs numbers as is (and ignores the `locales` and `options` props).
If Intl is not available, `<NumberField>` outputs numbers as is (and ignores the `locales` and `options` props).

{% raw %}
```jsx
Expand All @@ -496,8 +496,6 @@ import { NumberField } from 'react-admin';
```
{% endraw %}

See [Intl.NumberFormat documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString) for the `options` prop syntax.

**Tip**: If you need more formatting options than what `Intl.NumberFormat` can provide, build your own field component leveraging a third-party library like [numeral.js](http://numeraljs.com/).

**Tip**: When used in a `Show` view, the right alignment may look weird. Disable it by setting the `textAlign` attribute to "left":
Expand Down

0 comments on commit 4c62d18

Please # to comment.