- Input includes Default, Hover, Focus, Focus Visible, and Locked states.
- Focus is triggered by a mouse click.
- Focus Visible is triggered when the user navigates to the field using the Tab key.
- In both the Focus and Focus Visible states, a text caret appears to indicate that the user can enter a value.
- The Invalid validation state can only have Default and Hover states. When the user clicks on an Invalid Input, the validation is cleared and the component transitions to the Focus state. Pressing Tab instead transitions it to the Focus Visible state.
- The Validated validation state can only have Default and Hover states and applies only when the field contains user input. When the user clicks on a Validated Input, the validation is cleared and the component transitions to the Focus state. Pressing Tab instead transitions it to the Focus Visible state.
Input
Molecule
The Input component is a single-line form field for short text or numeric values. Use type="text" (default) for names and similar entries, and type="number" when a unit and numeric stepping are required. Text fields can show optional leading or trailing icons; number fields show a unit instead. Values that exceed the field width are truncated with an ellipsis.
Playground
<
Input
type
=
"text"
label
=
"Label"
placeholder
=
"Placeholder"
validation
=
"info"
tooltipPosition
=
"top-center"
helpText
=
"This is a help text"
maxLength
step
=
"0.01"
fractionDigits
=
"2"
range
=
"[
0,
150
]"
useHelpTextIcon
/>
ModelValues
For more information on ModelValues please have a look to the Vue's Data Binding section.
ts
const [modelValue, modifiers] = defineModel<string | number | null>('modelValue', {
required: true,
set: (value) => {
return applyBuiltInModelModifiers(value, modifiers);
}
});Properties
ts
export type InputProps =
& Omit<FormLabelOptionalProps, 'labelPosition' | 'clickableLabel'>
& {
type?: InputType;
placeholder?: string;
icon?: IconName;
iconRight?: boolean;
searchable?: boolean;
/** @deprecated Use `searchable`. */
deleteButton?: boolean;
validation?: HelpTextProps['category'];
maxLength?: number;
helpTextMaxLength?: string;
fractionDigits?: number;
step?: number;
unit?: Unit | string;
range?: [number | null, number | null];
};Anatomy
- Container - clickable area that enables and contains the user’s input.
- Form Label - nested FormLabel. Tells the user what they are entering and indicates if the field is required. Can be hidden.
- Icons - optional leading and/or trailing nested Icon. A leading icon hints at the input type. A trailing icon communicates an action. Number type does not show icons.
- Help Text - optional nested HelpText. Additional guidance, up to two lines. When a validation state is set, Help Text is used as feedback (valid or invalid) with the matching icon and color.
- Input value - placeholder until the user types. Do not put critical information in the placeholder; use the label or help text. Overflow is truncated with an ellipsis; the field does not grow or wrap.
- Unit (number type) - unit suffix inside the field (for example
cm,kN/m²) from theunitprop or#unitslot. Uses placeholder color when the field is empty, and error-red wheninvalid.
States
Variants
Type
- Text — expected input is text. Can be used with leading or trailing icons.
- Number — expected input is a number. Units are shown. Icons cannot be shown.
Searchable
- Available only for the Text type. When enabled, the trailing icon is replaced with an Icon Button that allows the user to clear the input field and reset the interface.
- The Searchable option is only active when the field contains user input (Text=Input), as a search field without typed content does not apply.
FormLabel
- Show or hide Form Label.
- Toggle Required.
Text
- Placeholder — sample to prompt user.
- Input — user generated.
Icons
- Leading, Trailing or None.
- A leading Icon hints at the input type. A trailing Icon communicates an action (for example a magnifier). Number type does not show icons.
Help Text + Validation
- Show or hide Help Text.
- The Input supports three validation states: None, Invalid, and Validated. When validation is applied, the Help Text communicates the current validation result.
- The Validated state is only available when the field contains user input, as an empty placeholder field cannot be positively validated.
- If the Input has informational Help Text and a validation state is triggered, the validation message replaces the original informational message. Validation feedback always takes priority over informational Help Text.
- Depending on the use case, validation may be triggered after the user submits the form or moves focus away from the Input after editing its value.
Developer notes
type="text"uses astringmodel.type="number"usesnumber | null.TextInputandNumberInputremain compatibility wrappers around Input (type="text"/type="number"). PreferInputin new code.searchableis text-only (defaulttrue). Empty fields show no trailing control; with a value, a clear IconButton replaces the trailing icon. Number type ignoressearchable.deleteButtonstill works as an alias ofsearchable. Prefersearchable.- Number type ignores icons. Arrow keys change the value while focused:
Arrow up/Arrow down:1 * stepCtrl+Arrow *:10 * stepCtrl+Shift+Arrow *:100 * step
- Values outside
rangeor with more thanfractionDigitsdecimal places show invalid Help Text.maxLengthdoes the same for text.
vue
<script setup>
import { ref } from 'vue';
import { Input } from '@pohlcon/design-system';
const name = ref('');
const query = ref('');
const length = ref<number | null>(null);
</script>
<template>
<Input
v-model="name"
label="Your Name"
placeholder="Dennis Neumann-Börtz"
helpText="Please enter your full name."
/>
<Input
v-model="query"
label="Search"
placeholder="Type here..."
searchable
/>
<Input
v-model="length"
type="number"
label="Length"
unit="cm"
helpText="The value should be max. 100 cm"
:range="[0, 100]"
/>
</template>