@s-ui/react-molecule-field
Version:
`MoleculeField` is a component that wraps a composition of Label + some input (input, textarea, ...) + Validation Messages.
74 lines (53 loc) • 2.45 kB
Markdown
# MoleculeField
`MoleculeField` is a component that wraps a composition of Label + some input (input, textarea, ...) + Validation Messages.
[](https://sui-components.vercel.app/workbench/molecule/field/)
[](https://github.com/SUI-Components/sui-components/issues/new?&projects=4&template=bug-report.yml&assignees=&template=report-a-bug.yml&title=🪲+&labels=bug,component,molecule,field)
[](https://www.npmjs.com/package/@s-ui/react-molecule-field)
[](https://github.com/SUI-Components/sui-components/issues?q=is%3Aopen+label%3Acomponent+label%3Afield)
[](https://github.com/SUI-Components/sui-components/blob/main/components/molecule/field/LICENSE.md)
## Installation
```sh
$ npm install @s-ui/react-molecule-field --save
```
## Usage
After importing the component `MoleculeField` like this
```javascript
import MoleculeField from '@s-ui/react-molecule-field'
```
### Basic usage
```
<MoleculeField label="name" name="name">
<input id="name" type="text"/>
</MoleculeField>
```
### With Error Message
```
<MoleculeField label="surname" name="surname" errorText="Error!">
<input id="surname" type="text"/>
</MoleculeField>
```
### With Success Message
```
<MoleculeField label="address" name="address" successText="Success!">
<input id="address" type="text"/>
</MoleculeField>
```
### With Alert Message
```
<MoleculeField label="address" name="address" alertText="Alert!">
<input id="address" type="text"/>
</MoleculeField>
```
### With Help Text
```
<MoleculeField label="country" name="country" helpText="Read the instructions to write proper format">
<input id="country" type="text"/>
</MoleculeField>
```
### Inline
```
<MoleculeField inline label="city" name="city">
<input id="city" type="text"/>
</MoleculeField>
```
> **Find full description and more examples in the [demo page](https://sui-components.now.sh/workbench/molecule/field/demo).**