Git Product home page Git Product logo

formik-material-ui's Introduction

Build Status license Coverage Status

Formik Material Ui

Bindings for using Formik with Material UI.

Getting Started

yarn add formik-material-ui

Goals

  • Convenience: This project containis mostly the tedious wrapper code needed to convert the formik field props to Material UI shapes. Which is why certain assumptions are made (See below). The mapping functions are exported so you can build on top of them for more specialized behavior

Form Behaviour Assumptions

  • Errors are only displayed on touched/dirty fields
  • Fields are disabled during submission

Non Goals

  • Negate the need to import Material UI directly or create custom components

FAQ

Custom onChange

import MuiTextField from '@material-ui/core/TextField';
import {fieldToTextField, TextField, TextFieldProps} from 'formik-material-ui';
...
const UppercasingTextField = (props: TextFieldProps) => (
  <MuiTextField
    {...fieldToTextField(props)}
    onChange={event => {
      const {value} = event.target;
      props.form.setFieldValue(
        props.field.name,
        value ? value.toUpperCase() : ''
      );
    }}
  />
);
...

Composing mappers

import {fieldToTextField} from 'formik-material-ui';

<Field name="name" render={(props) => (<div>
  <Comp1 {...fieldToText(props)}>
  <Comp2 {...fieldToText(props)}>
  ...
</div>)} />

Development

yarn install
yarn storybook

Running tests

yarn prepublishOnly

formik-material-ui's People

Contributors

cliedeman avatar cherniavskii avatar bfirsh avatar yardz avatar lironer avatar vegtelenseg avatar

Watchers

James Cloos avatar Rodrigo Cunha avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.