LogoLogo
  • Release Notes
  • Downloads
  • Frequently Asked Questions
  • Developers
    • Introduction
    • Color Variables
    • Font Family
    • Vanilla JS
    • React
    • Vue
    • Angular
    • RTL Support
    • Light Mode/Dark Mode
  • Foundations
    • Typography
    • Colors
    • Icons & Visuals
    • Images
    • Layout & Breakpoints
    • Utils
    • Usability Guidelines
  • Components
    • Accordions
      • Accordion
      • Accordion Groups
    • Alert
    • Attach File
    • Avatar
    • Banner Cards
    • Breadcrumbs
    • Buttons
      • Button
      • Icon Button
      • Link Button
      • Social Media Buttons
      • Split Button
    • Checkbox
      • Checkbox Input
      • Checkbox Groups
    • Chips
    • Credit Card
    • Credit Card Input Field
    • Header
    • Interactive Banner
    • Number Field
    • Menu
    • Pagination
    • Phone Number Field
    • Progress Indicators
      • Expectation Levels
      • Progress Bar
      • Progress Circle
      • Progress Semi-Circle
    • Quick Select Field
    • Radio Buttons
      • Radio Input
      • Radio Buttons Groups
    • Search Input Field
    • Segmentation
      • Segmented Controls
      • Segmented Tabs
    • Select Input Field
    • Slider
    • Steps
      • Stepper
      • Step Indicator
    • Sticky Bar
    • Tabs
    • Text Area Field
    • Text Field
    • Toggle Switch
    • Tooltip
Powered by GitBook
On this page
  • Overview
  • Usage
  • When to use this component?
  • How it works
  • Code
  • Properties
  • Anatomy
  • Anatomy Options
  • Dos and Don'ts
Export as PDF
  1. Components

Number Field

Number Input Field allows users to enter numeric values with precision, ideal for fields requiring quantities, amounts, or other numerical data.

PreviousInteractive BannerNextMenu

Last updated 12 days ago

Overview

Usage

When to use this component?

Number inputs are used in forms and other input scenarios where users need to enter numeric values, such as quantities, amounts, or measurements. They ensure consistent formatting, making it easier to validate and process the numeric data accurately.

How it works

A number input component typically includes a label, a number-formatted input area, and optional elements like placeholder text, helper text, and a stepper for incrementing or decrementing the value. It may have different states to indicate its status, such as focused, filled, or error, ensuring that the numeric input is entered correctly and within the expected range.

Code

<dda-number-field
    label="Amount"
    value=""
    placeholder="Enter amount"
    helper_text="Helper or footer text"
    error_message=""
    validation_type="normal"
    size="medium"
    input_status="normal"
    selected_currency="USD"
    custom_class=""
    component_mode=""
    input_id="input"
    aria_label="input"
    onchange=""
    input_name="input"
    toggle_button_name="toggle-button"
    currency_button_name="currency-button"
    currencies='["USD","EUR","GBP","AED","PKR"]'
></dda-number-field>
<DdaNumberField
    label="Amount"
    value=""
    placeholder="Enter amount"
    helper_text="Helper or footer text"
    error_message=""
    validation_type="normal"
    size="medium"
    input_status="normal"
    selected_currency="USD"
    custom_class=""
    component_mode=""
    input_id="input"
    aria_label="input"
    onchange=""
    input_name="input"
    toggle_button_name="toggle-button"
    currency_button_name="currency-button"
    currencies='["USD","EUR","GBP","AED","PKR"]'
></DdaNumberField>
<DdaNumberField
    label="Amount"
    value=""
    placeholder="Enter amount"
    helper_text="Helper or footer text"
    error_message=""
    validation_type="normal"
    size="medium"
    input_status="normal"
    selected_currency="USD"
    custom_class=""
    component_mode=""
    input_id="input"
    aria_label="input"
    onchange=""
    input_name="input"
    toggle_button_name="toggle-button"
    currency_button_name="currency-button"
    currencies='["USD","EUR","GBP","AED","PKR"]'
></DdaNumberField>
<dda-number-field
    label="Amount"
    value=""
    placeholder="Enter amount"
    helper_text="Helper or footer text"
    error_message=""
    validation_type="normal"
    size="medium"
    input_status="normal"
    selected_currency="USD"
    custom_class=""
    component_mode=""
    input_id="input"
    aria_label="input"
    onchange=""
    input_name="input"
    toggle_button_name="toggle-button"
    currency_button_name="currency-button"
    currencies='["USD","EUR","GBP","AED","PKR"]'
></dda-number-field>

Properties

Property
Description
Type

aria_label

An optional string for defining an accessible label for the input field, used by screen readers.

string

component_mode

A string that can be used to define different modes of the component (e.g., readonly, disabled).

string

currencies

A string containing a JSON array of currency options to display in the dropdown.

string

custom_class

An optional string for adding custom CSS classes to the component for styling purposes.

string

error_message

A string that displays an error message below the input field if there's an issue with the entered data (e.g., validation failure).

string

helper_text

A string that provides additional helper text below the input field, typically used to give guidance on acceptable input.

string

input_id

A unique string identifier for the input element, used for labeling and accessibility.

string

input_status

A string (in JSON format) that contains any status information related to the input (e.g., could be used for showing "loading" or "disabled" states).

string

label

A string that provides the label text for the input field, typically displayed above the input box.

string

placeholder

A string that defines the placeholder text shown inside the input field when it is empty.

string

selected_currency

A string representing the currency currently selected from the dropdown. Default is 'USD'.

string

size

A string that controls the size of the input field (e.g., small, medium, large).

string

validation_type

A string that represents the type of validation being applied to the input (e.g., required, numeric, etc.).

string

value

A string that holds the value of the input field.

string

input_name

Name attribute for the input field

string

toggle_button_name

Name attribute for the currency dropdown

string

currency_button_name

Name attribute for the currency switcher

string

Anatomy

Anatomy Options

Label: Positioned above the input field, the label ("Amount") indicates the purpose of the field, guiding users to input a specific monetary value.

Placeholder: The placeholder text within the input field provides an example format or prompt.

Lead Icon: Positioned to the left of the helper text, the lead icon provides a visual cue that can offer additional information or help related to the amount input.

Caption: Positioned below the input field, the caption provides additional instructions or context, such as "Helper or footer text," to assist users with the input.

Stepper: Positioned on the left within the input field, the stepper allows users to increase or decrease the amount by tapping up or down arrows, offering a quick way to adjust the input.

Currency Dropdown: Positioned to the right of the input field, the currency dropdown lets users select the desired currency, ensuring clarity in financial transactions.

Dos and Don'ts

Dos
Don'ts

Use number inputs to collect numeric values in a standardized format.

Don't use number inputs for non-numeric inputs.

Label the number input clearly to indicate its purpose.

Avoid using ambiguous or unclear labels for number inputs.

Include placeholder text to show the expected numeric format.

Don't rely solely on placeholder text for essential instructions.

Provide helper text to explain any specific formatting or range requirements.

Don't overload the number input with too much information.

Ensure the number input is large enough to be easily tappable or clickable.

Avoid making the number input too small to interact with comfortably.

Use the stepper for inputs that require incremental adjustments.

Don't use steppers if precise values are required without increments.

Validate input and provide clear error messages when the numeric format or range is incorrect.

Don't provide generic error messages that don't help users understand the issue.

Keep consistent styling and spacing across all number inputs in the application.

Don't use inconsistent styles that may confuse users.