Skip to content

gabriellfsouza/unform-material-ui

 
 

npm Build Status Coverage Status

Overview

This library uses Unform + Material UI styles to create super beautiful forms easily.

Table of contents

Roadmap

Installation

Just add unform to your project:

yarn add unform-material-ui @rocketseat/unform @material-ui/core

Guides

Basics

⚠️ This is a library that depends on Unform and Material UI to work, both must be installed in your project.

Components

️️⚠️ For now, all components of the Material UI are not yet supported. Below are just the supported components.

<TextField /> Component

The <TextField /> component, is similar to the default component <Input />. See the component documentation here for more information.

import React from 'react';
import { Form } from '@rocketseat/unform';
import { TextField } from 'unform-material-ui';

function App() {
  function handleSubmit(data) {}

  return (
    <Form onSubmit={handleSubmit}>
      <TextField name="name" />
      <TextField multiline name="bio" />

      <button type="submit">Send</button>
    </Form>
  );
}

<Select /> Component

The <Select /> component, is similar to the default component <Select />. See the component documentation here for more information.

import React from 'react';
import { Form } from '@rocketseat/unform';
import { Select } from 'unform-material-ui';

function App() {
  function handleSubmit(data) {
    /**
     * {
     *  "tech": ['node'],
     *  "country": "brazil"
     * }
     */
  }

  return (
    <Form onSubmit={handleSubmit}>
      <Select multiple name="tech" options={[
        { value: 'node', label: 'NodeJS' },
        { value: 'react', label: 'React' },
      ]} />

      <Select name="country" label="Country" options={[
        { value: 'brazil', label: 'Brazil' },
      ]} />

      <button type="submit">Send</button>
    </Form>
  );
}

<Checkbox /> Component

The <Checkbox /> component, is similar to the default component <Checkbox />. See the component documentation here for more information.

ℹ️ Because of component nature, he is not completely "not controlled" all the time. Internally he becomes a controlled component when passed a property checked as true.

import React from 'react';
import { Form } from '@rocketseat/unform';
import { Checkbox } from 'unform-material-ui';

function App() {
  function handleSubmit(data) {
    /**
     * {
     *  "terms": true,
     *  "acceptEmails": true
     * }
     */
  }

  return (
    <Form onSubmit={handleSubmit}>
      {/* not controlled */}
      <Checkbox name="terms" label="Terms & Conditions" />

      {/* internally controlled */}
      <Checkbox name="acceptEmails" label="I accept to receive promotional emails" checked />

      <button type="submit">Send</button>
    </Form>
  );
}

Contributing

Thanks for being interested on making this package better. We encourage everyone to help improving this project with some new features, bug fixes and performance issues. Please take a little bit of your time to read our guides, so this process can be faster and easier.

Contribution Guidelines

Take a moment to read about our Contribution Guidelines so you can understand how to submit an issue, commit and create pull requests.

Code of Conduct

We expect you to follow our Code of Conduct. You can read it to understand what kind of behaviour will and will not be tolerated.

License

MIT © Italo Izaac

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 81.0%
  • JavaScript 17.8%
  • HTML 1.2%