FormGroup

The FormGroup is a component that displays a label and an error message for a form input.

Installation

To install @igloo-ui/form-group in your project, you will need to run the following command using npm:

npm install @igloo-ui/form-group

If you prefer Yarn, use the following command instead:

yarn add @igloo-ui/form-group

Usage

Then to use the component in your code just import it!

import FormGroup from '@igloo-ui/form-group';
import Input from '@igloo-ui/input';

<FormGroup label="Name" errorMsg="Name is required" showError={true}>
  <Input type="text" placeholder="John Doe" error={true} />
</FormGroup>;

API

PropTypeDescription
childrenReactNodeThe form element that needs an error and/or a label.
classNamestringAdd a className for the form group div
dataTeststringAdd a data-test tag for automated tests
errorMsgstringAdd an error message below the form element
htmlForstringAdd the htmlFor attribute to the label of the form element
labelstringAdd label text above the form element
showErrorbooleanDecides when to show the error