Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/trendmicro-frontend/react-form-control

React Form Control component
https://github.com/trendmicro-frontend/react-form-control

Last synced: about 1 month ago
JSON representation

React Form Control component

Awesome Lists containing this project

README

        

# react-form-control [![build status](https://travis-ci.org/trendmicro-frontend/react-form-control.svg?branch=master)](https://travis-ci.org/trendmicro-frontend/react-form-control) [![Coverage Status](https://coveralls.io/repos/github/trendmicro-frontend/react-form-control/badge.svg?branch=master)](https://coveralls.io/github/trendmicro-frontend/react-form-control?branch=master)

[![NPM](https://nodei.co/npm/@trendmicro/react-form-control.png?downloads=true&stars=true)](https://nodei.co/npm/@trendmicro/react-form-control/)

React Form Control

Demo: https://trendmicro-frontend.github.io/react-form-control

## Installation

1. Install the latest version of [react](https://github.com/facebook/react) and [react-form-control](https://github.com/trendmicro-frontend/react-form-control):

```
npm install --save react @trendmicro/react-form-control
```

2. At this point you can import `@trendmicro/react-form-control` and its styles in your application as follows:

```js
import FormControl, { Input, Select, Textarea } from '@trendmicro/react-form-control';

// Be sure to include styles at some point, probably during your bootstraping
import '@trendmicro/react-form-control/dist/react-form-control.css';
```

## Overview

### Form controls

The `` component renders a form control with block-level styling (`display: block` and `width: 100%`). Supported textual form controls includes ``, ``, and ``.

```jsx

Email address

Example select

1
2
3
4
5

Example multiple select

1
2
3
4
5

Example textarea

```

### Form groups

Using the `` component is the easiest way to add some structure to forms, it provides a flexible way that encourages proper grouping of labels, controls, and form validation messaging.

The `` component is not provided here, but you can use [styled-components](https://github.com/styled-components/styled-components) to style with plain CSS styles. By default, it only applies `margin-bottom` as below:

```jsx
const FormGroup = styled.div`
margin-bottom: 12px;
`;
```

## API

### Properties

#### FromControl

Name | Type | Default | Description
:--- | :--- | :------ | :----------
tag | element | 'div' |
lg | boolean | |
md | boolean | | Defaults to 'md' if nothing is specified.
sm | boolean | |

#### Input

Name | Type | Default | Description
:--- | :--- | :------ | :----------
tag | element | 'input' |
lg | boolean | |
md | boolean | | Defaults to 'md' if nothing is specified.
sm | boolean | |

#### Select

Name | Type | Default | Description
:--- | :--- | :------ | :----------
tag | element | 'select' |
lg | boolean | |
md | boolean | | Defaults to 'md' if nothing is specified.
sm | boolean | |

#### Textarea

Name | Type | Default | Description
:--- | :--- | :------ | :----------
tag | element | 'textarea' |

## License

MIT