# General Translation React SDKs (gt-react, gt-next): Currency URL: https://generaltranslation.com/it/docs/react/reference/components/currency.mdx --- title: Currency description: Formatta un importo come Currency per l'impostazione regionale attiva con General Translation gt-react. Riferimento API per Currency. --- Il componente `` visualizza un valore numerico formattato come Currency per l'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`. Gli esempi importano da `gt-react`; importa invece dal pacchetto del framework che utilizzi.* ## Overview [#overview] Fornisci un importo come contenuto figlio e imposta il codice `currency`. ```tsx {100} // 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'importo viene formattato nel browser usando `Intl.NumberFormat`. L'importo non viene mai inviato all'API di General Translation. * **Nessuna conversione.** `` formatta il simbolo, il separatore delle migliaia e i decimali per la Currency e l'impostazione regionale selezionate, ma non converte tra valute. * **Risoluzione dell'impostazione regionale.** L'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'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'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] **Type** `Intl.NumberFormatOptions` · **Facoltativo** · **Predefinito** `{}` Opzioni di formattazione conformi alla specifica [`Intl.NumberFormatOptions`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat), come `currencyDisplay` e i limiti per le cifre decimali. ### `locales` [#locales] **Tipo** `string[]` · **Facoltativo** · **Predefinito** Impostazione regionale attiva Le impostazioni regionali da usare per la formattazione. Se omesse, viene usata l'impostazione regionale attiva. Vedi l'[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] ```tsx title="PriceDisplay.tsx" import { Currency } from 'gt-react'; export default function PriceDisplay({ item }) { return {item.price}; // [!code highlight] } ``` ```tsx title="PriceDisplay.tsx" import { Currency } from 'gt-react'; export default function PriceDisplay({ item }) { return {item.price}; // [!code highlight] } ``` ```tsx title="PriceDisplay.tsx" import { T, Currency } from 'gt-react'; export default function PriceDisplay({ item }) { return ( The price is {item.price}. // [!code highlight] ); } ``` ```tsx title="PriceDisplay.tsx" import { Currency } from 'gt-react'; export default function PriceDisplay({ item }) { return ( {item.price} ); } ``` ## Note [#notes] * `` formatta i valori Currency in base all'impostazione regionale attiva; non converte da una Currency all'altra. * Il suo contenuto viene formattato localmente e non viene mai inviato all'API.