Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

material-ui-formik-components

gerhat2.3kMIT0.7.3TypeScript support: included

We all love Material-UI and Formik, we just need an easy way to make them work seamlessly together. This library was built just for that.

react, formik, material-ui, form component, form, autocomplete, material-ui-pickers, material-ui-chip-input

readme

Material-UI Formik Components
NPM · Total Downloads · devDependency Status · npm bundle size

We all love Material-UI and Formik, we just need an easy way to make them work seamlessly together. This library was built just for that.

Installation

Install the material-ui-formik-components package using the following command:

$ npm install --save material-ui-formik-components

Peer dependencies

The extension depends on the following packages:

Required

Optional

Using the components

The following components are supported:

Below is an example of TextField and Select components. Code sandbox url: https://codesandbox.io/s/xoplpm1w84

import React from 'react'
import { Formik, Form, Field } from 'formik'
import { TextField } from 'material-ui-formik-components/TextField'
import { Select } from 'material-ui-formik-components/Select'

class RegistrationForm extends React.PureComponent {
  render() {
    return (
      <div>
        <h1>Register</h1>
        <Formik
          initialValues={{
            username: '',
            gender: 'Male',
          }}
          onSubmit={values => {
            alert(`Username: ${values.username}\nGender: ${values.gender}`)
          }}
        >
          {formik => (
            <Form>
              <Field name="username" label="Username" component={TextField} />
              <Field
                required
                name="gender"
                label="Gender"
                options={[
                  { value: 'Male', label: 'Male' },
                  { value: 'Female', label: 'Female' },
                  { value: 'Other', label: 'Other' },
                ]}
                component={Select}
              />
              <button type="submit" disabled={!formik.dirty}>
                Submit
              </button>
            </Form>
          )}
        </Formik>
      </div>
    )
  }
}

export default RegistrationForm

Example

For a more detailed use of the package, please refer to the code in the example folder of this project.

License

MIT

changelog

Versions

0.7.3

Oct 22, 2020
  • Switch: fixed warning for changing from uncontrolled to controlled state
  • Autocomplete: fixed TypeScript autocomplete props interface extension
  • Updated dependencies in main project

0.7.2

Sept 6, 2020
  • Fixed Issue: #40 - cannot read property 'formControl' of undefined thanks @wsmith2020
  • Added RadioGroup to SimpleExample demo
  • Updated devDependencies in main project
  • Updated dependencies and devDependencies in example project

0.7.1

May 12, 2020
  • Moved @material-ui/pickers, @date-io/date-fns, date-fns and material-ui-chip-input to optionalDependencies Issue: #33 thanks @depiction
  • Updated dev dependencies to latest versions

0.7.0

May 2, 2020
  • Added Support for Keyboard Pickers ( KeyboardDatePicker, KeyboardTimePicker, KeyboardDateTimePicker and TimePicker) PR: #30 thanks @shtjefeen
  • Updated SimpleFormExample.jsx to use Keyboard Pickers

0.6.3

May 2, 2020
  • Fixed handling of null initial values at AutoComplete with prop multiple. Issue: #31 thanks @shtjefeen
  • Updated packages to latest versions

0.6.2

Apr 23, 2020
  • Fixed initial values not being displayed at AutoComplete. Issue: #28
  • Updated examples to demonstrate the initialValues prop
  • Updated packages to latest versions

0.6.1

Mar 29, 2020
  • Package updates for fixing minimist security vulnerability

0.6.0

Mar 8, 2020

General

  • Updated library and example packages to the latest versions
  • Refactored Formik code in example/src/SimpleFormExample.jsx to not use the render prop

Autocomplete

  • Replaced react-select with @material-ui/lab/Autocomplete for improved compatibility

Breaking changes

  • Prop isMultiple has been changed to multiple
  • Props label and required must be provided as items in textFieldProps props e.g.
    textFieldProps={{
      label: 'Country',
      required: true,
      variant: 'outlined',
    }}

    Select

  • Simplified select component by replacing @material-ui/core/Select with @material-ui/core/TextField + select prop (see: https://material-ui.com/components/text-fields/#select)

0.5.2

Nov 24, 2019
  • Added missing ts export for <DatePicker/> - thanks @cargallo

0.5.1

Nov 09, 2019

0.5.0

Nov 09, 2019

0.4.1

Sep 16, 2019
  • Updated dependencies to the latest version

0.4.0

Jun 2, 2019
  • Added support for Material UI v4
  • Replaced material-ui-pickers v2 with @material-ui/pickers v3

0.3.0

Apr 26, 2019
  • Added ChipInput component based on material-ui-chip-input
  • Improved code quality and styling using eslint-config-airbnb, prettier and husky

0.2.4

Apr 06, 2019
  • Fixed error in RadioGroup PropTypes

0.2.3

Apr 06, 2019
  • Added the ability to fully customize RadioGroup

0.2.2

Mar 20, 2019
  • Resolved InputProps ambiguity in TextField component (issue: #6)

0.2.1

Mar 19, 2019
  • Breaking: Added prop isMultiple in Autocomplete and set it false by default
  • Improved example and removed react-scripts

0.2.0

Feb 23, 2019
  • Added DateTimePicker, RadioGroup and Switch components
  • Added default value for required prop
  • Updated README
  • Minor refactoring in typescript definitions for OptionsType

0.1.5

Feb 19, 2019
  • Props fullWidth and margin are not hard-coded anymore
  • Fixed Autocomplete typescript definitions
  • Bumped up formik version to 1.5.1 and react-select to 2.4.1
  • Added information about the example in README

0.1.4

Feb 17, 2019
  • Breaking: Changed default error behavior. Errors now appear only when the field is touched (issue: #2)
  • Added the ability to show error messages in Select
  • Fixed asterisk not showing in Autocomplete label when required is true
  • Error message in TextField is now displayed only when there is an error
  • Updated devDependencies in package.json
  • Added validation to the example project
  • Updated dependencies in example's package.json
  • Minor typo in README

0.1.3

Jan 10, 2019
  • Added Typescript types
  • Minor refactoring in Autocomplete.jsx and Select.jsx
  • Added npm package link to README

0.1.2

Sept 20, 2018
  • Fixed a typo in README
  • Moved react-select to peer dependencies

0.1.1

Sept 20, 2018
  • Added react-dom to peer dependencies
  • Added example to README

0.1.0

Sept 18, 2018
  • Initial commit