Input
<afp-input>
Short summary of the component's intended use.
Examples #
Shape #
Use the shape attribute to change a input's shape.
Sizes #
Use the size attribute to change a input's size.
Label #
Use the label attribute or slot to set the Input's label.
Use the tooltip attribute to show the label's text as a tooltip when hovering on the label.
Types #
Use the type attribute to set the Inputs's semantic type.
Password #
Use the passwordToggle (passwordtoggle) attribute in password Input to enable the password toggle feature.
You can provide custom icons for the password password-toggle-show and the password-toggle-hide slots.
Number #
Use the min and max attribute in number Input to set the Quantity for example (between 10 and 20) .
Date #
Use the min and max attribute in the date Input to set the date of Birth for example (between 01.01.2000 and 20.01.2020).
Decimal #
In the decimal input expect the value attribute to be viewed with respect to the decimal attribute.
Use the decimalConfig (decimalconfig) property to change how the value gets displayed.
Keys #
Use the allowedKeys (allowedkeys) attribute on the keys input to to restrict which keys are accepted. For example, allowedKeys=[1,2,3] allows only 1, 2, and 3; any other key presses are ignored. Additionally, if the value already contains disallowed characters, they will be removed from the value.
Prefix and Suffix #
Use the input-prefix slot to add prefix to the Input field.
Use the input-suffix slot to add suffix to the Input field.
Hint #
Use the hint attribute to provide additional information below the input field.
Pattern #
Use the pattern attribute to validate the input against a regular expression.
Enforce Pattern #
Use the enforcePattern (enforcepattern) attribute along with pattern to prevent users from entering characters that don't match the pattern. This provides real-time input restriction rather than just validation.
Letters Only #
Only alphabetic characters (A-Z, a-z) are allowed.
Numbers Only #
Only numeric characters (0-9) are allowed.
Clearable #
Use the clearable attribute to display a clear button when the input has a value.
Clearable with Custom Icon #
Use the clear-icon slot to customize the clear button icon.
Disabled #
Use the disabled attribute specifies whether the input is disabled.
Invalid #
Use the invalid attribute specifies the error message.
Properties
Learn more about properties.
| Name | Description | Reflects | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type
|
type of input field
Type
AfpInputType
Default
AfpInputType.TEXT |
|
||||||||||||||||
size
|
size of the input.
Type
AfpSize
Default
AfpSize.MEDIUM |
|
||||||||||||||||
shape
|
shape of the tag
Type
AfpShape
Default
AfpShape.ROUNDED |
|
||||||||||||||||
min
|
The input’s minimum value.
Only applies to date and number input types.
Type
number
|
|
||||||||||||||||
max
|
The input’s maximum value.
Only applies to date and number input types.
Type
number
|
|
||||||||||||||||
disabled
|
disabled property of input
Type
boolean
|
|
||||||||||||||||
passwordToggle
passwordtoggle
|
passwordToggle property of input
Type
boolean
|
|
||||||||||||||||
required
|
enables required flag of input
Type
boolean
|
|
||||||||||||||||
name
|
html name attribute of input
Type
string
|
|||||||||||||||||
tooltip
|
show label tooltip by hover
Type
boolean
|
|
||||||||||||||||
value
|
value of input field
Type
string
|
|
||||||||||||||||
ariaLabel
arialabel
|
Aria label for the input field.
This is used for accessibility purposes to provide a text alternative for screen readers.
Type
string
|
|
||||||||||||||||
decimalConfig
decimalconfig
|
Decimal configuration for the input. Required type AfpInputType.DECIMAL
Type
AfpInputDecimal
Default
{ options: { places: 2, sign: ',', delimiter: '.' }, decimalInOut: true, focusAutoFill: false, } |
|||||||||||||||||
allowedKeys
allowedkeys
|
Allowed keys configuration for the input. Required type afpInputType.KEYS
Type
string[]
Default
[ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Backspace', 'ArrowLeft', 'ArrowRight', 'Delete', 'Tab', ] |
|||||||||||||||||
label
|
label header property of input
Type
string
|
|||||||||||||||||
placeholder
|
placeholder property of input
Type
string
|
|||||||||||||||||
autocorrect
|
enables autocorrect on input
Type
boolean
|
|
||||||||||||||||
autocomplete
|
list of autocomplete strings
Type
string
Default
'off' |
|
||||||||||||||||
pattern
|
A regular expression pattern to validate input against.
Type
string
|
|
||||||||||||||||
enforcePattern
enforcepattern
|
When true, enforces the pattern by preventing input that doesn't match.
Characters that don't match the pattern will be blocked.
Type
boolean
Default
false |
|
||||||||||||||||
autofocus
|
enables autofocus on input
Type
boolean
|
|||||||||||||||||
inputTabIndex
inputtabindex
|
html tabIndex property of button
Type
number
|
|||||||||||||||||
invalid
|
validation footer property of input
Type
string
|
|
||||||||||||||||
hint
|
hint footer property of input
Type
string
|
|
||||||||||||||||
hideLabel
hidelabel
|
hides the label visually
Type
boolean
|
|
||||||||||||||||
clearable
|
Adds a clear button when the input has a value.
Type
boolean
Default
false |
|
Events
Learn more about events.
| Name | Return | Description |
|---|---|---|
afp-clear
|
void
|
Emitted when the input is cleared.
|
afp-focus
|
void
|
Emitted when the input gains focus.
|
afp-blur
|
void
|
Emitted when the input loses focus.
|
afp-select
|
string
|
afp-select - Emitted when part of input gets selected.
|
afp-value-changed
|
string
|
Emitted when the input's value changes.
|
Slots
Learn more about slots.
| Name | Description |
|---|---|
label
|
Slot for adding custom label content
|
input-prefix
|
Slot for adding content before the input field
|
input-suffix
|
Slot for adding content after the input field
|
password-toggle-show
|
Slot for adding a custom show password icon
|
password-toggle-hide
|
Slot for adding a custom hide password icon
|
clear-icon
|
Slot for customizing the clear icon
|
Internationalization
Learn more about internationalization.
| Key | Description |
|---|---|
input.password-toggle.show
|
The show password icon in the password input with password toggle property enabled.
|
input.password-toggle.hide
|
The hide password icon in the password input with password toggle property enabled.
|
input.clear-button.aria-label
|
The aria-label of the input's clear button.
|
CSS Parts
Learn more about CSS Parts.
| Name | Description | Selector |
|---|---|---|
base
|
The base container for the input
|
::part(base)
|
label
|
The container for the input's label
|
::part(label)
|
label-base
|
The base part of the label
|
::part(label-base)
|
input-text
|
The part for the text input element
|
::part(input-text)
|
input-number
|
The part for the number input element
|
::part(input-number)
|
input-email
|
The part for the email input element
|
::part(input-email)
|
input-password
|
The part for the password input element
|
::part(input-password)
|
input-decimal
|
The part for the decimal input element
|
::part(input-decimal)
|
input-keys
|
The part for the keys input element
|
::part(input-keys)
|
input-date
|
The part for the date input element
|
::part(input-date)
|
field
|
The part for the small size input field
|
::part(field)
|
disabled
|
The part for the disabled state of the input
|
::part(disabled)
|
invalid-base
|
The base container for the invalid message
|
::part(invalid-base)
|
invalid
|
The part for the invalid message
|
::part(invalid)
|
hint-base
|
The base container for the hint message
|
::part(hint-base)
|
hint
|
The part for the hint message
|
::part(hint)
|
password-toggle-button
|
The part for the password toggle icon wrapper
|
::part(password-toggle-button)
|
password-toggle-icon
|
The part for the password toggle icon
|
::part(password-toggle-icon)
|
clear-icon
|
The part for the clear icon
|
::part(clear-icon)
|
clear-button
|
The part for the clear button
|
::part(clear-button)
|
input-actions
|
The part for the input action icons container
|
::part(input-actions)
|
CSS Custom Properties
| Name | Description | Default |
|---|---|---|
--afp-input-label-disabled-opacity
|
The opacity of the input label when disabled.
|
0.5
|
--afp-input-field-disabled-opacity
|
The opacity of the input field when disabled.
|
0.5
|
--afp-input-error-label-color
|
The color of the label in the invalid/error state.
|
--afp-color-error-500
|
--afp-input-error-border-color
|
The border color of the input field in the invalid/error state.
|
--afp-color-error-500
|
--afp-input-error-message-color
|
The color of the error message in the invalid/error state.
|
--afp-color-error-500
|
Dependencies
The component automatically brings in the listed items, including any nested dependencies that may exist.
Importing
Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.
import '@afp-design-system/core/dist/components/input/input.js';