logo dile-components dile-components

dile-input-number

This component extends from dile-input.

This component is customized to introduce numeric values while normalizing decimal separators. You can choose which separator you want to use and if the user types the alternative one, the component transforms it automatically.

value is always stored in canonical format using . as decimal separator. The decimalSeparator property only affects what users see in the input field.

Install

npm install @dile/ui

Usage

Import the component.

import '@dile/ui/components/input/input-number';

Use the component

<dile-input-number
  name="amount"
  label="Amount"
></dile-input-number>

Properties

The same as dile-input and:

Custom style

By default, this input component aligns the input text to the right. If you want to align to the left you may use --dile-input-number-text-align CSS custom property.

dile-input-number demos

Regular number input

<dile-input-number name="amount" label="Amount" placeholder="12.75"></dile-input-number>

Decimal separator ","

<dile-input-number decimalSeparator="," name="amount_eu" label="Importe" placeholder="12,75"></dile-input-number>

Constraints with min, max, step and decimals

<dile-input-number min="1" max="10" step="0.25" decimals="2" name="range_amount" label="Range amount" placeholder="1.00 - 10.00"></dile-input-number>

Normalize separator on blur

<dile-input-number decimalSeparator="," normalizeOn="blur" name="lazy_amount" label="Amount" placeholder="Write 12.75"></dile-input-number>