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

react-accessible-form

v2.2.1

Published

React Accessible Form handles makes layout and accessibility easy when writing forms.

Downloads

839

Readme

React Accessible Form

React Accessible Form handles makes layout and accessibility easy when writing forms.

GitHub license npm version test coverage code style: prettier bundle size

Try the other libaries in the series! React Stateful Tabs, React Smart Promise, React Use Pagination

Example

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

Without react-accessible-form:

<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 />
        <small>Separated by semicolon (;)</small>
    </div>
</div>

Features

  • Optionally generates a unique id for the label’s htmlFor and input’s id props and links them
  • Applies BEM-formatted classNames to all of the components to make theming straightforward
  • Allows usage of any custom controls with as prop on Form.Control
  • Zero-overhead integration with form state libraries like Formik and React-Final-Form
  • Optional set of base styles that help with aligned form layouts

Form Props

as

Type: React.ElementType Required: false Default: "form"

Changes the underlying element of the Form component.

disabled

Type: boolean Required: false Default: false

Sets the disabled prop on all children Form.Control components.

layout

Type: "stacked" | "aligned" Required: false Default: "stacked"

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

id

Type: string Required: false Default: UUIDv4()

The id to set on the Form.Control and associated htmlFor to set on the Form.Label

required

Type: boolean Required: false Default: false

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

disabled

Type: boolean Required: false Default: false

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

Form.Control Props

as

Type: React.ElementType Required: false Default: "input"

Examples

Built-in element
<Form.Control as="select">
    <option value="AL">Alabama</option>
    <option value="AK">Alaska</option>
    <option value="AZ">Arizona</option>
</Form.Control>
Custom element
<Form.Control as={ReactSelect} options={[{value: "AL", label: "Alabama"}]} />
Overriding props
<Form.Control as={({className, ...props}) => <ReactSelect className="custom" {...props} />} />