Skip to content

currency

The module currency is a function that formats numbers to currency

TIP

This module uses the native api Intl.NumberFormat from browsers

Enter only numbers

formatted value: 69,00 €
vue
<template>
  <MazInput v-model="numberValue" type="number" />

  <div
    style="padding: 16px; margin-top: 16px; background-color: var(--maz-color-bg-lighter);"
  >
    {{ priceFormatted }}
  </div>
</template>

<script lang="ts" setup>
  import { currency } from 'maz-ui'
  import { ref, computed } from 'vue'

  const numberValue = ref(69)

  const priceFormatted = computed(() =>
    currency(numberValue.value, 'fr-FR', { currency: 'EUR' }),
  )
</script>

Options

All options from Intl.NumberFormat are availables

ts
export interface FilterCurrencyOptions extends Intl.NumberFormatOptions {
  round?: boolean
}