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. You can also pass any HTML attributes, such as onClick, role, etc. Which attributes are available depends on whether or not you have overriden the underlying HTML element using the as property.
- className
stringSpecifies class name to append to the base element.
- as
elementTypeDefault'input'Specifies base element for the control component.
- onChange
funcSpecifies function that is triggered on input value change.
- defaultValue
string|numberSpecifies default value of the input component.
- value
string|numberSpecifies current value of the input component.
- id
stringSpecifies id of the control component.
- controlClassName
stringSpecifies class name for the control component.
- size
enum'sm' | 'lg'Specifies size for the control component.
- leadingElement
nodeSpecifies leading element to display for the input component.
- trailingElement
nodeSpecifies trailing element to display for the input component.
- floatingLabel
nodeSpecifies floating label to display for the input component.
- plaintext
boolDefaultfalseSpecifies whether to render input as plain text.
- isValid
boolSpecifies whether to display control in valid state, this affects styling.
- isInvalid
boolSpecifies whether to display control in invalid state, this affects styling.
- autoResize
boolDefaultfalseOnly for
as="textarea". Specifies whether the input can be resized according to the height of content. - inputMask
stringSpecifies what format to use for the input mask.
Usage Insights#
FormControl
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| frontend-app-authn | 23.14.0 | 1 | |
| frontend-app-communications | 23.12.2 | 1 | |
| frontend-app-communications | 23.12.2 | 1 | |
| frontend-app-course-authoring | 23.14.9 | 1 |