Changelog Azalea Kit UI 101 Usage Customizing Utilities Form controls Laravel Vue FHIR Types Accessibility Icons Actions Button Button group Layout and structure Card Card section Care summary Care timeline Divider Empty state Footer Header Layout Stack Table Selection and input Calendar Checkbox Checkbox group Color picker Combobox Combobox option Input Input mask Memorable date Number input Option Phone input Radio Radio button Radio group Range Select SSN input Tag Textarea Toggle ZIP code input Images and icons Avatar Icon Icon button Logo Feedback indicators Badge Banner Progress bar Skeleton Skeleton body text Skeleton display text Skeleton thumbnail Spinner Typography Text Navigation Breadcrumb Breadcrumb item Dropdown Menu Menu item Menu label Navigation Nav group Nav item Nav toggle Pagination Tab Tab group Tab panel Top bar Tree Tree item User menu Overlays Dialog Popover Tooltip Utilities Collapsible FHIR address FHIR human name FHIR quantity FHIR questionnaire Format bytes Format date Format number Relative time Resize observer Split panel Tooltip Border Color Shadow Spacing Transition Typography Z-index Contributing Visual Tests Light Dark System

Format Number

<ahi-format-number> | AhiFormatNumber

Formats a number using the specified locale and options. Localization is handled by the browser’s Intl.NumberFormat API. No language packs are required.


<ahi-format-number value="1000"></ahi-format-number><br />
<ahi-format-number value="1000000"></ahi-format-number>

Examples

Percentages

To get the value as a percent, set the type attribute to percent.






<ahi-format-number type="percent" value="0"></ahi-format-number><br />
<ahi-format-number type="percent" value="0.25"></ahi-format-number><br />
<ahi-format-number type="percent" value="0.50"></ahi-format-number><br />
<ahi-format-number type="percent" value="0.75"></ahi-format-number><br />
<ahi-format-number type="percent" value="1"></ahi-format-number><br />
<ahi-format-number type="percent" value="1.25"></ahi-format-number>

Currency

To format a number as a monetary value, set the type attribute to currency and set the currency attribute to the desired ISO 4217 currency code.

<ahi-format-number type="currency" value="1337.42"></ahi-format-number>

Units

To format a number as a unit, set the type attribute to unit and set the unit attribute to the desired ECMAScript sanctioned unit.






<ahi-format-number type="unit" value="42" unit="centimeter"></ahi-format-number><br />
<ahi-format-number type="unit" value="98.5" unit="fahrenheit"></ahi-format-number><br />
<ahi-format-number type="unit" value="6" unit="foot"></ahi-format-number><br />
<ahi-format-number type="unit" value="42" unit="inch"></ahi-format-number><br />
<ahi-format-number type="unit" value="2" unit="meter"></ahi-format-number><br />
<ahi-format-number type="unit" value="25" unit="pound"></ahi-format-number>

Importing

Script Bundler

To import this component using a script tag:

<script type="module" src="/path/to/azalea-kit-ui/dist/components/format-number/format-number.js"></script>

To import this component using a bundler:

import '@azaleahealth/azalea-kit-ui/dist/components/format-number/format-number.js';

Properties

Name Description Type Default
value The number to format. number 0
type The formatting style to use. 'currency' | 'decimal' | 'percent' | 'unit' 'decimal'
noGrouping
no-grouping
Turns off grouping separators. boolean false
currency The ISO 4217 currency code to use when formatting. string 'USD'
currencyDisplay
currency-display
How to display the currency. 'symbol' | 'narrowSymbol' | 'code' | 'name' 'symbol'
unit The ECMAScript sanctioned unit to use when formatting. string ''
unitDisplay
unit-display
How to display the unit. 'long' | 'short' | 'narrow' 'short'
minimumIntegerDigits
minimum-integer-digits
The minimum number of integer digits to use. Possible values are 1–21. number -
minimumFractionDigits
minimum-fraction-digits
The minimum number of fraction digits to use. Possible values are 0–100. number -
maximumFractionDigits
maximum-fraction-digits
The maximum number of fraction digits to use. Possible values are 0–100. number -
minimumSignificantDigits
minimum-significant-digits
The minimum number of significant digits to use. Possible values are 1–21. number -
maximumSignificantDigits
maximum-significant-digits
The maximum number of significant digits to use,. Possible values are 1–21. number -
updateComplete A read-only promise that resolves when the component has finished updating.

Learn more about properties and attributes.