-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Mantine UI Series] Form, Part I #18
Comments
Form Usage ScenariosNow let's explore some common form usage in frontend development:
|
The Form DesignThe section covers three topics:
Afterward, we will delve into the details of the above points. What components/hooks are exposed for developer users to use?The most common pattern for designing highly customized components has two forms:
|
The Form State and API designFrom an end-users' perspective, the key aspects of the form state that we care about are:
const [touched, setTouched] = useState(initialTouched);
const [dirty, setDirty] = useState(initialDirty);
const [values, _setValues] = useState(initialValues);
const [errors, _setErrors] = useState(filterErrors(initialErrors)); Correspondingly,
// The params available to initialize for the form
export function useForm<
Values = Record<string, unknown>,
TransformValues extends _TransformValues<Values> = (values: Values) => Values
>({
initialValues = {} as Values,
initialErrors = {},
initialDirty = {},
initialTouched = {},
clearInputErrorOnChange = true,
validateInputOnChange = false,
validateInputOnBlur = false,
validate: rules,
} // The values/functions exposed for the `useForm` hook
return {
values,
errors,
setValues,
setErrors,
setFieldValue,
setFieldError,
clearFieldError,
clearErrors,
reset,
validate,
onSubmit,
onReset,
isDirty,
isTouched,
setTouched,
setDirty,
resetTouched,
resetDirty,
isValid,
}; |
Introduction
This article discuss
Mantine UI Form
component in React. The main topics covered include:Given the fact that form solutions are highly customized based on real-world use cases, our analysis starts with examining usage scenarios.
The best practices are covered in Mantine UI Form Part II
The text was updated successfully, but these errors were encountered: