0.3.4 • Published 3 years ago

@blackbox-vision/rff-material-ui v0.3.4

Weekly downloads
22
License
MIT
Repository
github
Last release
3 years ago

RFF Material UI

Material UI Wrapper for React Final Form

Table of contents

Use Case

You're working with react-final-form on web and you need bindings between material-ui and react-final-form.

Compatibility

Since this package uses hooks under the hood, you need at least a minimum React version of 16.8.0.

Installation

YARN

yarn add @blackbox-vision/rff-material-ui

NPM

npm install --save @blackbox-vision/rff-material-ui

Example Usage

After reading and performing the previous steps, you should be able to import the library and use it like in this example:

import React from 'react';
import { Form, Field } from 'react-final-form';
import { TextInput } from '@blackbox-vision/rff-material-ui';

const onSubmit = async (values: any) => alert(JSON.stringify(values, null, 2));

const MyForm = (props: any) => (
  <Form
    onSubmit={onSubmit}
    render={({ handleSubmit }) => (
      <form onSubmit={handleSubmit}>
        <Field
          {...args}
          name="email"
          variant="filled"
          component={TextInput}
          validate={value => (value ? undefined : 'Required')}
        />
        <button type="submit">Send</button>
      </form>
    )}
  />
);

MyForm.displayName = 'MyForm';

export default MyForm;

Storybook

You can run a playground to test components locally. To do this, run the npm run storybook command. Once Storybook server is started, open a browser tab and go to http://localhost:6006/ to start.

Component APIs

TextInput

The TextInput component has the following props:

PropertiesTypesDefault ValueRequiredDescription
namestring-YesProperty that represents the name of input
labelstring-NoProperty that represents the label to show
classesobject-NoOverride or extend the styles applied to the component.
variantstring"standard"NoProperty that represents the variant of text input

The TextInput also inherits its own props from material-ui.

Select

The Select component has the following props:

PropertiesTypesDefault ValueRequiredDescription
namestring-YesProperty that represents the name of input
labelstring-NoProperty that represents the label to show
variantstring"standard"NoProperty that represents the variant of text input
optionsarray-YesProperty that represents the options to choose

The Select also inherits its own props from material-ui.

Checkbox

The Checkbox component has the following props:

PropertiesTypesDefault ValueRequiredDescription
namestring-YesProperty that represents the name of input
labelstring-NoProperty that represents the label to show
classesobject-NoOverride or extend the styles applied to the component.
iconnode"standard"NoThe icon to display when the component is unchecked.

The Checkbox also inherits its own props from material-ui.

RadioGroup

The RadioGroup component has the following props:

PropertiesTypesDefault ValueRequiredDescription
namestring-YesProperty that represents the name of input
labelstring-NoProperty that represents the label to show
optionsarray[]NoProperty that represents the options of radio buttons group

The RadioGroup also inherits its own props from material-ui.

DatePicker

The DatePicker component has the following props:

PropertiesTypesDefault ValueRequiredDescription
namestring-YesProperty that represents the name of input
labelstring-NoProperty that represents the label to show

The DatePicker also inherits its own props from material-ui-pickers.

Issues

Please, open an issue following one of the issues templates. We will do our best to fix them.

Contributing

If you want to contribute to this project see contributing for more information.

License

Distributed under the MIT license. See LICENSE for more information.

0.3.4

3 years ago

0.3.2

3 years ago

0.3.3

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.0.2

3 years ago

0.0.0

3 years ago