mui / mui/base-ui

[form] Support resetting a form to initial values

Open
#1,346 2 comments 2 reactions 0 assignees View on GitHub
component: form type: new feature
Dominant language
TypeScript
Stars
10.9k
Forks
543
Avg merge
1d 20h
Merged PRs (30d)
101

Description

# Feature request

## Summary

The `Form` component supports a native submit button - `` - but not a reset button:

```jsx
console.log('submitted')}>

{/* a normal Field.Control that renders an input */}

{/* works */}

Submit

{/* doesn't work */}

Reset

```

## Examples in other libraries

- [React Aria](https://react-spectrum.adobe.com/react-aria/Form.html#events) provides a reset button ``
- [React Hook Form](https://www.react-hook-form.com/faqs/#Howtoresettheform) 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`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.