# General Translation React SDKs (gt-react, gt-next, gt-react-native): `<Currency>`
URL: https://generaltranslation.com/it/docs/react/reference/components/currency.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Formatta un importo in Currency per l'impostazione regionale attiva. Riferimento API per il componente `<Currency>`.

Il componente `<Currency>` visualizza un valore numerico formattato come Currency per l&#39;impostazione regionale attiva. Si limita alla formattazione: non esegue la conversione del tasso di cambio.

*Disponibile in `gt-react`, `gt-next`, `gt-tanstack-start` e `gt-react-native`.*

## Overview [#overview]

Fornisci un importo come contenuto figlio e imposta il codice `currency`.

```tsx
<Currency>{100}</Currency>
// Output: $100.00
```

Tutta la formattazione viene gestita localmente con [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).

## Come funziona [#how-it-works]

* **Formattazione locale.** L&#39;importo viene formattato nel browser usando `Intl.NumberFormat`. L&#39;importo non viene mai inviato all&#39;API di General Translation.
* **Nessuna conversione.** `<Currency>` formatta il simbolo, il separatore delle migliaia e i decimali per la Currency e l&#39;impostazione regionale selezionate, ma non converte tra valute.
* **Risoluzione dell&#39;impostazione regionale.** L&#39;impostazione regionale attiva determina la formattazione, a meno che non venga sovrascritta con `locales`.

## Props [#props]

| Prop                    | Descrizione                                                    | Type                       | Facoltativo | Predefinito                   |
| ----------------------- | -------------------------------------------------------------- | -------------------------- | ----------- | ----------------------------- |
| [`children`](#children) | Il valore da formattare.                                       | `number \| string`         | No          | —                             |
| [`currency`](#currency) | Codice Currency ISO 4217.                                      | `string`                   | Sì          | `USD`                         |
| [`options`](#options)   | Opzioni di `Intl.NumberFormat`.                                | `Intl.NumberFormatOptions` | Sì          | `{}`                          |
| [`locales`](#locales)   | Sovrascrive l&#39;impostazione regionale per la formattazione. | `string[]`                 | Sì          | Impostazione regionale attiva |
| [`name`](#name)         | Nome della variabile per la voce.                              | `string`                   | Sì          | —                             |

### `children` [#children]

**Tipo** `number | string` · **Obbligatorio**

L&#39;importo da formattare come Currency. Le stringhe vengono convertite in numeri prima della formattazione.

### `currency` [#currency]

**Tipo** `stringa` · **Facoltativo** · **Predefinito** `USD`

Il codice di Currency ISO 4217, ad esempio `USD` o `EUR`. Determina il simbolo e la formattazione.

### `options` [#options]

**Tipo** `Intl.NumberFormatOptions` · **Facoltativo** · **Predefinito** `{}`

La prop accetta [`Intl.NumberFormatOptions`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options). Tra le opzioni più comuni:

| Opzione                    | Descrizione                                                                                  | Tipo                                                                                                                 | Facoltativo | Predefinito                               |
| -------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------- | ----------------------------------------- |
| `localeMatcher`            | Algoritmo di corrispondenza dell&#39;impostazione regionale.                                 | `'lookup' \| 'best fit'`                                                                                             | Sì          | `'best fit'`                              |
| `numberingSystem`          | Sistema di numerazione, ad esempio `latn` o `arab`.                                          | `string`                                                                                                             | Sì          | `'latn'`                                  |
| `style`                    | Stile di formattazione dei numeri.                                                           | `'decimal' \| 'currency' \| 'percent' \| 'unit'`                                                                     | Sì          | `'currency'`                              |
| `currency`                 | Codice Currency ISO 4217. Se specificato qui, sostituisce la prop `currency` di primo livello. | `string`                                                                                                             | Sì          | prop `currency`                           |
| `currencyDisplay`          | Modalità di visualizzazione della Currency.                                                    | `'code' \| 'symbol' \| 'narrowSymbol' \| 'name'`                                                                     | Sì          | `'symbol'`                                |
| `currencySign`             | Notazione standard o contabile per i valori negativi.                                        | `'standard' \| 'accounting'`                                                                                         | Sì          | `'standard'`                              |
| `unit`                     | Identificatore dell&#39;unità usato se `style` è impostato su `'unit'`.                      | `string`                                                                                                             | Sì          | —                                         |
| `unitDisplay`              | Lunghezza dell&#39;etichetta dell&#39;unità.                                                 | `'long' \| 'short' \| 'narrow'`                                                                                      | Sì          | `'short'`                                 |
| `minimumIntegerDigits`     | Numero minimo di cifre intere; i valori più brevi vengono completati con zeri.               | `number` (`1`–`21`)                                                                                                  | Sì          | `1`                                       |
| `minimumFractionDigits`    | Numero minimo di cifre dopo il separatore decimale.                                          | `number` (`0`–`100`)                                                                                                 | Sì          | Dipende dalla Currency                      |
| `maximumFractionDigits`    | Numero massimo di cifre dopo il separatore decimale.                                         | `number` (`0`–`100`)                                                                                                 | Sì          | Dipende dalla Currency                      |
| `minimumSignificantDigits` | Numero minimo di cifre significative.                                                        | `number` (`1`–`21`)                                                                                                  | Sì          | `1`                                       |
| `maximumSignificantDigits` | Numero massimo di cifre significative.                                                       | `number` (`1`–`21`)                                                                                                  | Sì          | `21`                                      |
| `roundingPriority`         | Stabilisce se hanno la priorità le cifre frazionarie o quelle significative.                 | `'auto' \| 'morePrecision' \| 'lessPrecision'`                                                                       | Sì          | `'auto'`                                  |
| `roundingIncrement`        | Incremento usato al livello di arrotondamento selezionato.                                   | `1 \| 2 \| 5 \| 10 \| 20 \| 25 \| 50 \| 100 \| 200 \| 250 \| 500 \| 1000 \| 2000 \| 2500 \| 5000`                    | Sì          | `1`                                       |
| `roundingMode`             | Direzione da usare per l&#39;arrotondamento.                                                 | `'ceil' \| 'floor' \| 'expand' \| 'trunc' \| 'halfCeil' \| 'halfFloor' \| 'halfExpand' \| 'halfTrunc' \| 'halfEven'` | Sì          | `'halfExpand'`                            |
| `trailingZeroDisplay`      | Stabilisce se mantenere gli zeri finali nei numeri interi.                                   | `'auto' \| 'stripIfInteger'`                                                                                         | Sì          | `'auto'`                                  |
| `notation`                 | Notazione standard, scientifica, ingegneristica o compatta.                                  | `'standard' \| 'scientific' \| 'engineering' \| 'compact'`                                                           | Sì          | `'standard'`                              |
| `compactDisplay`           | Etichette estese o abbreviate per la notazione compatta.                                     | `'short' \| 'long'`                                                                                                  | Sì          | `'short'`                                 |
| `useGrouping`              | Quando visualizzare i separatori delle migliaia.                                             | `boolean \| 'always' \| 'auto' \| 'min2'`                                                                            | Sì          | `'auto'`; `'min2'` con notazione compatta |
| `signDisplay`              | Quando visualizzare un segno positivo o negativo.                                            | `'auto' \| 'always' \| 'exceptZero' \| 'negative' \| 'never'`                                                        | Sì          | `'auto'`                                  |

Il componente applica `style: 'currency'`, la prop `currency` di primo livello e `numberingSystem: 'latn'` prima di applicare `options`. I valori specificati tramite `options` sostituiscono quindi questi valori predefiniti.

* I valori predefiniti per le cifre frazionarie delle valute derivano dalle rispettive unità minori standard.
* `compactDisplay` si applica solo quando `notation` è `'compact'`.
* `roundingIncrement` non può essere combinato con l&#39;arrotondamento per cifre significative né con un `roundingPriority` diverso da `'auto'`.
* Le unità supportate, i sistemi di numerazione, i campi di arrotondamento e i valori delle opzioni dipendono dal runtime JavaScript.

Consulta la [documentazione delle opzioni di `Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options) per conoscere le opzioni più recenti disponibili e il comportamento del runtime.

### `locales` [#locales]

**Tipo** `string[]` · **Facoltativo** · **Predefinito** Impostazione regionale attiva

Le impostazioni regionali da usare per la formattazione. Se omesse, viene usata l&#39;impostazione regionale attiva. Vedi l&#39;[argomento locales](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).

### `name` [#name]

**Type** `stringa` · **Opzionale**

Un nome facoltativo per il campo Currency, usato come metadato.

## Esempi [#examples]

*Gli esempi importano da `gt-react`; importa invece dal pacchetto del tuo framework.*

```tsx title="PriceDisplay.tsx"
import { Currency } from 'gt-react';

export default function PriceDisplay({ item }) {
  return <Currency>{item.price}</Currency>; // [!code highlight]
}
```

```tsx title="PriceDisplay.tsx"
import { Currency } from 'gt-react';

export default function PriceDisplay({ item }) {
  return <Currency currency="EUR">{item.price}</Currency>; // [!code highlight]
}
```

```tsx title="PriceDisplay.tsx"
import { T, Currency } from 'gt-react';

export default function PriceDisplay({ item }) {
  return (
    <T>
      The price is <Currency>{item.price}</Currency>. // [!code highlight]
    </T>
  );
}
```

```tsx title="PriceDisplay.tsx"
import { Currency } from 'gt-react';

export default function PriceDisplay({ item }) {
  return (
    <Currency
      currency="GBP"
      options={{ // [!code highlight]
        currencyDisplay: 'narrowSymbol',
        minimumFractionDigits: 2,
        maximumFractionDigits: 2,
      }}
    >
      {item.price}
    </Currency>
  );
}
```

## Note [#notes]

* `<Currency>` formatta i valori Currency in base all&#39;impostazione regionale attiva; non converte da una Currency all&#39;altra.
* Il suo contenuto viene formattato localmente e non viene mai inviato all&#39;API.

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
