Input fields
Angular Bootstrap 5 Input fields
Input fields refer specifically to the text input fields, which are used to obtain data from the users.
Basic example
A basic example of the input field consists of the input
element with specified
ID
and label
element connected via this ID
with the
input. Both elements are wrapped in .form-outline
class which provides a material
design look.
Sizing
Set heights using classes like .form-control-lg
and
.form-control-sm
.
Disabled
Add the disabled
boolean input on an element with mdbInput
directive
to give it a grayed out appearance and remove pointer events.
Readonly
Add the readonly
boolean input on an element with mdbInput
directive
to prevent modification of the input’s value. Read-only inputs appear lighter (just like
disabled inputs), but retain the standard cursor.
Types
Input types let you specified what data users should provide and help you validate it.
Text
The input type="text"
defines a single-line text field.
The input field type="email"
defines the email address field. The input value is automatically validated to ensure that it is a properly formatted email address
Password
The input field type="password"
defines a password field, thus hiding characters as confidential information.
Number
The input type="number"
defines field for entering a number.
Phone number
The input type="tel"
defines a field for entering a telephone number.
URL
The input type="url"
defines a field for entering a URL.
Textarea
The textarea
tag defines a multi-line text input control.
Text
Block-level or inline-level form text can be created using .form-text
.
Associating form text with form controls
Form text should be explicitly associated with the form control it relates to using the
aria-describedby
attribute. This will ensure that assistive technologies—such as
screen readers—will announce this form text when the user focuses or enters the control.
Form text below inputs can be styled with .form-text
. If a block-level element
will be used, a top margin is added for easy spacing from the inputs above.
Inline text can use any typical inline HTML element (be it a <span>
,
<small>
, or something else) with nothing more than the
.form-text
class.
Character counter
With the help of form-helper
, form-counter
classes and input's
maxlength
attribute you can easily create a character counter.
Dark background
When placing an input on the dark background add .form-white
class next to
.form-outline
to provide proper contrast.
Input fields - API
Import
Inputs
Name | Type | Default | Description |
---|---|---|---|
disabled |
Boolean | false |
Changes input disabled state |
readonly |
Boolean | false |
Changes input readonly state |
value |
any | - |
Changes input value |