npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mui-rhf-components

v1.0.4

Published

MUI-RHF-components is a library that extracts common Material UI and React-Hook-Form integrations. This library provides building blocks to quickly start building forms without limiting any of the customizability that MUI offers. All of the props exposed

Downloads

12

Readme

MUI-RHF-components

MUI-RHF-components is a library that extracts common Material UI and React-Hook-Form integrations. This library provides building blocks to quickly start building forms without limiting any of the customizability that MUI offers. All of the props exposed by MUI are still accessible.

Prerequisites

Install react-hook-form and material-ui

npm install react-hook-form @material-ui/core

Installation

npm install mui-react-hook-form

Quick Start

import {
  CheckboxGroup,
  Form,
  RadioButtonGroup,
  SelectInput,
  TextField
} from 'mui-react-hook-form'
import { useForm } from 'react-hook-form'
import { Button } from '@material-ui/core'

const App = () => {
  const formMethods = useForm()
  const onSubmit = (submittedData) => console.log(submittedData)

  return (

      <Form
        formMethods={formMethods}
        onSubmit={onSubmit}>
        <TextField name="firstName" label="first name" />
        <SelectInput
          name="state"
          label="State"
          options={[
            { value: 'IL', label: 'Illinois' },
            { value: 'MO', label: 'Missouri' }
          ]}
        />
        <CheckboxGroup
          name="foods"
          label="Foods I Like"
          options={[
            { value: 'pizza', label: 'Pizza' },
            { value: 'salad', label: 'Salad' }
          ]}
        />
        <RadioButtonGroup
          name="favoriteColor"
          label="Favorite Color"
          options={[
            { value: 'red', label: 'Red' },
            { value: 'blue', label: 'Blue' }
          ]}
        />
        <Button type="submit">Submit</Button>
      </Form>
    </div>
  )
}

export default App

Examples

Basic Example

Validation Example

InitializedData Example

Custom Styles Example

API

Form

| Props | Options | Required | Description | | ----------- | ---------------------------------------------------------------- | -------- | ------------------------------------------------------------------ | | formMethods | useForm return values | x | this prop provides the RHF form Methods to all children components | | onSubmit | function handler | x | hanldes submit event |

Any other props that are given will be passed down to the form component

TextField

| Props | Options | Required | Description | | ------------------ | ------------------------------------------------------------------------------ | -------- | ---------------------------------------------------------------------------------------- | | name | string | x | Unique Name for RHF | | label | string | | input label | | defaultValue | string or number | | Default Value for Controller | | required | boolean | | adds required validation to useController hook as well as the MUI input | | useControllerProps | useControllerProps | | allows access to RHF useController Prop |

Any other props that are given will be passed down to the input component

SelectInput

| Props | Options | Required | Description | | ------------------ | ------------------------------------------------------------------------------ | -------- | ---------------------------------------------------------------------------------------- | | name | string | x | Unique Name for RHF | | options | { value: any; label: string }[] | x | select options | | label | string | | input label | | required | boolean | | adds required validation to useController hook as well as the MUI input | | defaultValue | string or number | | Default Value for Controller | | useControllerProps | useControllerProps | | allows access to RHF useController Prop |

Any other props that are given will be passed down to the input component

Checkbox Group

| Props | Options | Required | Description | | --------------------- | --------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------- | | name | string | x | Unique Name for RHF | | options | { value: any; label: string }[] | x | value/label for checkbox | | label | string | | label for group | | controllerProps | controllerProps | | allows access to RHF useController Prop | | formLabelProps | formLabelProps | | allows access to MUI formLabel Prop | | formGroupProps | formGroupProps | | allows access to MUI formGroup Prop | | formControlProps | formControlProps | | allows access to MUI formControl Prop | | formControlLabelProps | formControlLabelProps | | allows access to MUI formControlLabel Prop | | checkboxProps | checkboxProps | | allows access to MUI Checkbox Prop |

RadioButtonGroup

| Props | Options | Required | Description | | --------------------- | --------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------- | | name | string | x | Unique Name for RHF | | options | { value: any; label: string }[] | x | value/label for checkbox | | label | string | | label for group | | defaultValue | string or number | | Default Value for Controller | | useControllerProps | useControllerProps | | allows access to RHF useController Prop | | formLabelProps | formLabelProps | | allows access to MUI formLabel Prop | | radioGroupProps | radioGroupProps | | allows access to MUI radioGroup Prop | | formControlProps | formControlProps | | allows access to MUI formControl Prop | | formControlLabelProps | formControlLabelProps | | allows access to MUI formControlLabel Prop | | radioProps | checkboxProps | | allows access to MUI Radio Prop |

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.