/formland-material-ui

Formland component with Material UI

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

formland-material-ui Build Status

This is a collection of Material UI input components for Formland

Formland Material

Table of Contents

Get started

Installation

npm i formland formland-material-ui

or

yarn add formland formland-material-ui

Example

import React, { Component } from 'react'
import { componentResolver, valueResolver } from 'formland-material-ui' // Yay!
import Form from 'formland'

class Example extends Component {
  state = {}

  onChange = (newState) => {
    this.setState(newState)
  }

  render() {
    const config = [
      {
        id: 'firstName',
        type: 'material-text', // this is where we defined out custom Material UI field
        resultPath: 'country',
        displayName: 'Shipping Country',
        placeholder: 'Select a country',
        options: [
          {
            value: 'india',
            label: 'India',
          },
          {
            value: 'usa',
            label: 'The United States',
          },
          {
            value: 'china',
            label: 'China',
          }
        ],
      },
    ]

    // Right here we use the custom component and value resolver from this library
    return <Form
      customComponentResolvers={[componentResolver]}
      customValueResolvers={[valueResolver]}
      config={config}
      store={this.state}
      onChange={this.onChange} />
  }
}

API

componentResolver

Component resolver for Formland prop customComponentResolvers

Parameters

Returns JSX.Element

valueResolver

Value resolver for Formland prop customValueResolvers

Parameters

Returns Function

Fields

components

Available fields types

Properties