0.8.1 • Published 8 years ago

react-forms-ui v0.8.1

Weekly downloads
9
License
Apache 2
Repository
github
Last release
8 years ago

React Forms UI

A comprehensive UI toolbox for React.

1. Demo

The live demo.

2. Install

Install the node package:

npm i -S react-forms-ui

Import .css files and initialize React Forms UI in your index.js file:

import 'bootstrap/dist/css/bootstrap.css'
import 'font-awesome/css/font-awesome.css'
import 'select2/select2.css'
import 'react-forms-ui/lib/react-forms-ui.css'
import {initialize} from 'react-forms-ui'
initialize()

3. Usage

import React, {Component} from 'react'
import {Form, TextField, PasswordField, NumberField, DateField} from 'react-forms-ui'
import {Grid, Panel} from 'react-bootstrap'

const validations = {
  myText: {
    required: true,
    minLength: 4,
    maxLength: 10,
  },
  myNumber: {
    required: true,
  },
}

export default React.createClass({
  getInitialState() {
    return {}
  },
  render() {
    const fieldClasses = 'col-sm-2,col-sm-6,col-sm-4' // label,input,error
    return (
      <Grid fluid>
        <Form state={this.state} setState={this.setState.bind(this)} validations={validations}
              onSubmit={this.onSubmit}>
          <Panel header={<h3>My form</h3>}>
            <TextField id="myText" label="My text" placeholder="Enter some text" classes={fieldClasses}/>
            <PasswordField id="myPassword" label="My password" classes={fieldClasses}/>
            <NumberField id="myNumber" label="My number" format="0,0.[00]" classes={fieldClasses}/>
            <DateField id="myDate" label="My date" classes={fieldClasses}/>
          </Panel>
        </Form>
      </Grid>
    )
  },
  onSubmit() {
    const {values} = this.state
    console.log(values)
  }
})

See the source files of the demo for a comprehensive working usage example.

For a yet more complex example check out a sample front-end application at https://github.com/ivos/react-frontend.

4. Development

Development.

0.8.1

8 years ago

0.8.0

8 years ago

0.7.0

8 years ago

0.6.0

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago