Form.Control
A form control renders a space for user input (input
or select
). It can be
decorated with leading or trailing elements, and have a floating label.
Prefer to use the Form.Control component inside a Form.Group
. The Form.Group
provides a context for the control to ensure accessibility requirements for
labels and descriptions are met.
Note: extra props added to this component are passed as attributes to the
underlying DOM node (input
by default). See MDN for documentation on available
input attributes
or select attributes.
Usage with decorators and floating label
Any Paragon component or export may be added to the code example.
Input types
Any Paragon component or export may be added to the code example.
Input masks
Paragon uses the react-imask library,
which allows you to add masks of different types for inputs.
To create your own mask, you need to pass the required mask pattern (+{1} (000) 000-0000
) to the inputMask
property.
See react-imask for documentation on available props.
Any Paragon component or export may be added to the code example.
Input masks with clear value
To get a value without a mask, you need to use onChange
instead of onAccept
to handle changes.
Any Paragon component or export may be added to the code example.
Textarea autoResize
autoResize
prop allows input to be resized according to the content height.
Any Paragon component or export may be added to the code example.
Validation
Any Paragon component or export may be added to the code example.
Sizes
Any Paragon component or export may be added to the code example.
Theme Variables#
CSS Variable | Computed Value |
---|---|
| |
| |
| |
| |
| |
Props API#
This is a pass through component from React-Bootstrap, see original props documentation here.
- className
string
Specifies class name to append to the base element.
- as
elementType
Default'input'Specifies base element for the control component.
- onChange
func
Specifies function that is triggered on input value change.
- defaultValue
string
|number
Specifies default value of the input component.
- value
string
|number
Specifies current value of the input component.
- id
string
Specifies id of the control component.
- controlClassName
string
Specifies class name for the control component.
- size
enum
'sm' | 'lg'Specifies size for the control component.
- leadingElement
node
Specifies leading element to display for the input component.
- trailingElement
node
Specifies trailing element to display for the input component.
- floatingLabel
node
Specifies floating label to display for the input component.
- plaintext
bool
DefaultfalseSpecifies whether to render input as plain text.
- isValid
bool
Specifies whether to display control in valid state, this affects styling.
- isInvalid
bool
Specifies whether to display control in invalid state, this affects styling.
- autoResize
bool
DefaultfalseOnly for
as="textarea"
. Specifies whether the input can be resized according to the height of content. - inputMask
string
Specifies what format to use for the input mask.
Usage Insights#
FormControl
Project Name | Paragon Version | Instance Count | |
---|---|---|---|
frontend-app-admin-portal | 20.46.3 | 1 | |
frontend-app-learner-dashboard | 20.46.2 | 2 | |
frontend-lib-content-components | 21.5.6 | 1 | |
prospectus | 20.46.2 | 1 |