Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-boring-form

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-boring-form

React Boring Form handles all of the layout boilerplate (the boring part) that’s necessary when writing forms.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

React Boring Form · GitHub license npm version test coverage flow coverage code style: prettier

React Boring Form handles all of the layout boilerplate (the boring part) that’s necessary when writing forms.

Example

Before

<div className="form-group form-group--aligned">
    <div className="form-group-section">
        <label for="email_field" className="form-label--required">
            Email Addresses
        </label>
    </div>
    <div className="form-group-section">
        <input type="email" class="form-control" id="email_field" required />
        <span className="form-text">Separated by semicolon (;)</span>
    </div>
</div>

After

<Form.Group layout="aligned" required>
    <Form.Label>Email Addresses</Form.Label>
    <Form.Control type="email" />
    <Form.Text>Separated by semicolon (;)</Form.Text>
</Form.Group>

Features

  • Generates a unique id for the label’s htmlFor and input’s id props and links them
  • Applies classNames in a predictable way that reduces boilerplate and provides maximum flexibility
  • Allows usage of any custom inputs with render prop on Form.Control
  • Zero-overhead integration with form state libraries like Formik and React-Final-Form
  • Optional tiny set of base styles that help with aligned form layouts

Form Props

layout?: "stacked" | "aligned"

Propagates down to all of the children Form.Group components. stacked is the default, which is to set all of the children to display: block. aligned splits all of Form.Group’s children into two groups: "label", and "rest" so that all of the form’s labels will align to the same width.

Form.Group Props

required?: boolean

Set classNames on the label to indicate a required field, and set the required prop on the Form.Control

disabled?: boolean

Set classNames on the label to indicate a disabled field, and set the disabled prop on the Form.Control

Custom Inputs

The default behavior of Form.Control is to configure an input element and render it. If you want to use something else, like a select, textarea, or a third-party library component, you can render your own component without losing the benefits of React Boring Form:

{
    /* If the controls map to standard HTML attribute names, you can spread the props directly */
}
<Form.Control render={props => <textarea {...props} />} />;

{
    /* Otherwise, you can destructure the props and apply however is necessary */
}
<Form.Control
    render={({ className, disabled, id, required }) => (
        <SomeCustomInputComponent
            className={className}
            isDisabled={disabled}
            htmlId={id}
            isRequired={required}
        />
    )}
/>;

Keywords

FAQs

Package last updated on 28 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc