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

[Form] Support resetting a form to initial values #1346

Open
mj12albert opened this issue Jan 20, 2025 · 0 comments
Open

[Form] Support resetting a form to initial values #1346

mj12albert opened this issue Jan 20, 2025 · 0 comments
Labels
component: form This is the name of the generic UI component, not the React module! new feature New feature or request

Comments

@mj12albert
Copy link
Member

mj12albert commented Jan 20, 2025

Feature request

Summary

The Form component supports a native submit button - <button type="submit"> - but not a reset button:

<Form onSubmit={() => console.log('submitted')}>
   <Field.Root>
     {/*  a normal Field.Control that renders an input */}
   </Field.Root>

   {/* works */}
   <button type="submit">
     Submit
   </button>

   {/* doesn't work */}
   <button type="reset">
     Reset
   </button>
</Form>

Examples in other libraries

  • React Aria provides a reset button <Form><Button type="reset" /></Form>
  • React Hook Form supports a native reset button and also a reset() method via a hook

Motivation

It's often useful to be able to discard all edits in a form and reset it to the initial values. This will could require Fields to additionally track the initialValue.

@mj12albert mj12albert added component: form This is the name of the generic UI component, not the React module! new feature New feature or request labels Jan 20, 2025
@github-project-automation github-project-automation bot moved this to Backlog in Base UI Jan 20, 2025
@mj12albert mj12albert changed the title [Form] Support form reset [Form] Support resetting a form to initial values Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: form This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

1 participant