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
  • Options
Export as PDF
  1. Components

Text Field

Text Field allows users to input text into a UI. It is commonly used in forms and dialogs.

PreviousText Area FieldNextToggle Switch

Last updated 2 months ago

Overview

Usage

When to use this component?

Text fields are used in forms and input scenarios where users need to provide information such as names, addresses, passwords, or search queries. They are versatile and can be applied in various contexts, including modal windows, standalone forms, and inline editing.

How it works

A text field component typically includes a label, an input area, and optional helper or placeholder text to guide the user. It can display different states—such as focused, filled, or error—to indicate its current status. Text fields are a core interactive element, designed to capture user input accurately and efficiently.

Code

<dda-input
    placeholder="Enter text"
    label="Text Input"
    value=""
    type="text"
    size="default"
    helper_text="Helper or footer text"
    error_message=""
    validation_type="normal"
    custom_class=""
    component_mode=""
    input_id="input"
    aria_label="input"
    onchange="console.log('changed')"
></dda-input>
    <DdaInput
            placeholder="Enter text"
            label="Text Input"
            value=""
            type="text"
            size="default"
            helper_text="Helper or footer text"
            error_message=""
            validation_type="normal"
            custom_class=""
            component_mode=""
            input_id="input"
            aria_label="input"
            onchange="console.log('changed')"
        ></DdaInput>
    <DdaInput
            placeholder="Enter text"
            label="Text Input"
            value=""
            type="text"
            size="default"
            helper_text="Helper or footer text"
            error_message=""
            validation_type="normal"
            custom_class=""
            component_mode=""
            input_id="input"
            aria_label="input"
            onchange="console.log('changed')"
        ></DdaInput>
<dda-input
    placeholder="Enter text"
    label="Text Input"
    value=""
    type="text"
    size="default"
    helper_text="Helper or footer text"
    error_message=""
    validation_type="normal"
    custom_class=""
    component_mode=""
    input_id="input"
    aria_label="input"
    onchange="console.log('changed')"
></dda-input>

Properties

Property
Description
Type

aria_label

The ARIA label for accessibility. It provides a textual description of the input field for screen readers to improve accessibility for users with disabilities.

string

component_mode

Defines the mode in which the component should behave (e.g., 'edit', 'view'). This can be used for switching between different states or appearances.

string

custom_class

A custom CSS class that can be applied to the input container for further customization of the component's styling.

string

error_message

The message displayed when the input has a validation error, informing the user what went wrong.

string

helper_text

Additional text that can be shown below the input field, often used to provide helpful information or guidance to the user.

string

input_id

The unique identifier for the input field. It is used for associating the label with the input and can also be used for targeting the field programmatically.

string

input_status

Indicates the status of the input field, such as 'valid', 'invalid', 'disabled', etc., which affects the field's styling or interaction.

string

label

The label text displayed for the input field. It helps users understand the purpose of the input.

string

placeholder

The placeholder text that appears in the input field when it is empty. This provides a hint for what type of input is expected.

string

size

Specifies the size of the input field, typically values like 'small', 'medium', or 'large'. This adjusts the width or height of the input to fit the design.

string

type

Specifies the type of input, such as 'text', 'password', 'email', etc. It determines the input field's behavior and appearance.

string

validation_type

Defines the type of validation applied to the input field (e.g., 'required', 'email', 'minLength', etc.). It is used to determine the visual style or validation behavior.

string

value

The current value of the input field. It represents what the user has entered or is displayed in the field.

string

Anatomy

Anatomy Options

Label: The descriptive text indicating the purpose of the input field.

Placeholder: Temporary text within the input field that gives a hint about the expected input format or content.

Lead-Icon: An optional icon before the input field that provides additional context or helps identify the type of input.

Caption: Additional helper or instructional text below the input field to guide the user.

Trail-Text: Text at the end of the input field that often shows a character count, limit, or related information.

Dos and Don'ts

Dos
Don'ts

Use clear and concise labels that describe the expected input.

Don't use ambiguous or unclear labels.

Provide placeholder text to give users an example of the expected input format.

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

Ensure text fields are large enough to be easily tappable or clickable.

Avoid making text fields too small to interact with comfortably.

Use helper text to provide additional context or instructions.

Don't overload the text field with too much information.

Ensure text fields have a visible focus state to aid keyboard navigation.

Don't ignore accessibility requirements, such as contrast and focus indicators.

Validate input and provide clear error messages when necessary.

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

Keep consistent styling and spacing across all text fields in the application.

Don't use inconsistent styles that may confuse users.

Options

Types

Label: Indicates whether the text field should have a visible label. Labels help users understand what information is expected.

Value: The actual text input by the user or the default value displayed in the text field.

Placeholder: Text displayed inside the text field when it is empty, providing a hint to the user about the expected input.

HelperText: Additional text that provides more information or instructions about the text field.

States

Unfilled: Default state when the text field is empty and not focused.

Focused-Filled: State when the text field is filled and focused.

Filled: State when the text field is filled but not focused.

Error: State indicating that there is an error with the input.

Disabled: State indicating that the text field is not interactive.

Focused-Unfilled: State when the text field is empty but focused.

Sizes

Default: Standard size for most use cases.

Small: Smaller variant for compact spaces or less prominent input fields.

Background

No: Default state with no background.

Yes: Background enabled for additional emphasis or aesthetic purposes.