DevExtreme v26.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

Angular Number Box - Formatting

Use the format property to specify the integer, currency, accounting, percent, and other formats of the NumberBox value.

Backend API
<div class="dx-fieldset"> <div class="dx-field"> <div class="dx-field-label">Integer format</div> <div class="dx-field-value"> <dx-number-box format="#" [value]="14500" [inputAttr]="{ 'aria-label': 'Integer Format' }" ></dx-number-box> </div> </div> <div class="dx-field"> <div class="dx-field-label">Currency format</div> <div class="dx-field-value"> <dx-number-box format="$ #,##0.##" [value]="14500.55" [inputAttr]="{ 'aria-label': 'Currency Format' }" ></dx-number-box> </div> </div> <div class="dx-field"> <div class="dx-field-label">Accounting format</div> <div class="dx-field-value"> <dx-number-box format="$ #,##0.##;($ #,##0.##)" [value]="-2314.12" [inputAttr]="{ 'aria-label': 'Accounting Format' }" ></dx-number-box> </div> </div> <div class="dx-field"> <div class="dx-field-label">Percent format</div> <div class="dx-field-value"> <dx-number-box format="#0%" [value]="0.15" [step]="0.01" [inputAttr]="{ 'aria-label': 'Percent Format' }" ></dx-number-box> </div> </div> <div class="dx-field"> <div class="dx-field-label">Fixed point format</div> <div class="dx-field-value"> <dx-number-box format="#,##0.00" [value]="13415.24" [inputAttr]="{ 'aria-label': 'Fixed Point Format' }" ></dx-number-box> </div> </div> <div class="dx-field"> <div class="dx-field-label">Weight format</div> <div class="dx-field-value"> <dx-number-box format="#0.## kg" [value]="3.14" [inputAttr]="{ 'aria-label': 'Weight Format' }" ></dx-number-box> </div> </div> </div>
import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, provideZoneChangeDetection } from '@angular/core'; import { DxNumberBoxModule } from 'devextreme-angular'; if (!/localhost/.test(document.location.host)) { enableProdMode(); } @Component({ selector: 'demo-app', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], imports: [ DxNumberBoxModule, ], }) export class AppComponent {} bootstrapApplication(AppComponent, { providers: [ provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }), ], });
::ng-deep .dx-field { margin-bottom: 20px; }
<!DOCTYPE html> <html lang="en"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" /> </head> <body class="dx-viewport"> <div class="demo-container"> <demo-app>Loading...</demo-app> </div> <script src="https://cdn.jsdelivr.net/npm/zone.js@0.16.2/bundles/zone.umd.js"></script> <script src="./bundle.js" type="module"></script> </body> </html>

The format property can accept the following value types:

  • Predefined format
    See the type property description for a list of accepted values.

  • Custom format string
    Use a LDML pattern to specify a custom format. Refer to the following article for more information: Custom Format String.

  • Function
    A function should apply a custom format to a value and return the formatted value as a string. Functions are useful for advanced formatting.

  • Object
    Full format configuration. The object structure is shown in the format API section.