JSPM

  • Created
  • Published
  • Downloads 538505
  • Score
    100M100P100Q181520F
  • License MIT

Autogenerate IDs to facilitate WAI-ARIA and server rendering.

Package Exports

  • @reach/auto-id

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@reach/auto-id) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@reach/auto-id

Stable release MIT license

Docs | Source

Autogenerate IDs to facilitate WAI-ARIA and server rendering.

A string can be supplied as an argument to be useId in lieu of the auto-generated ID. This is handy for accepting user-provided prop IDs that need to be deterministic.

import { useId } from "@reach/auto-id";

function FormField(props) {
    const id = useId(props.id);
    return (
        <React.Fragment>
            <label htmlFor={id}>{props.label}</label>
            <input type={props.type} name={props.name} id={id} />
        </React.Fragment>
    );
}