Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: useField instance returns label component. #380

Open
smurrayatwork opened this issue Jun 24, 2020 · 0 comments
Open

[Feature Request]: useField instance returns label component. #380

smurrayatwork opened this issue Jun 24, 2020 · 0 comments
Labels
legacy Issues or pull requests relating to the legacy version of the forms library

Comments

@smurrayatwork
Copy link

smurrayatwork commented Jun 24, 2020

It'd be nice if useField could optionally return a FieldLabel component that references the field with htmlFor automatically. FieldLabel would render a <label> element. The field would need to set its id attribute for htmlFor as well. Perhaps it could use the field path?

const {
    FieldLabel,
    meta: { error, isTouched, isValidating },
    getInputProps
  } = useField(field, fieldOptions);
return (
  <>
    <FieldLabel />
    <input {...getInputProps()} />
  </>
);
@crutchcorn crutchcorn added the legacy Issues or pull requests relating to the legacy version of the forms library label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy Issues or pull requests relating to the legacy version of the forms library
Projects
None yet
Development

No branches or pull requests

2 participants