@reach-ui-fork/auto-id
TypeScript icon, indicating that this package has built-in type declarations

0.18.1 • Public • Published

@reach-ui-fork/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-ui-fork/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>
	);
}

Dependencies (1)

Dev Dependencies (6)

Package Sidebar

Install

npm i @reach-ui-fork/auto-id

Weekly Downloads

851

Version

0.18.1

License

MIT

Unpacked Size

15.8 kB

Total Files

10

Last publish

Collaborators

  • yozi