# Form
`useForm` is the hook for managing form state: it holds the field values, tracks which fields
have been touched or changed, runs validation, and produces the props each input needs. You
connect a field to the form by spreading `getInputProps('name')` onto an input — that wires up
its value, `onChange`, `onBlur`, current error, and the key the hook uses to address the field.
Submitting goes through `onSubmit(handler)`: it runs every validation rule first, shows the
error messages on any field that fails, and only calls your handler — with the collected values
— once the whole form is valid. That gives you controlled inputs, inline validation, and a
clean submit path without hand-wiring `useState` for every field.
Because `useForm` is a hook with no component of its own, this page ships a worked example as
the `{% ContactForm %}` snippet: three fields (name, email, message), one
plain validation rule each, and a result area that prints the values when the form passes.
## Live example
Submit with empty or invalid fields to see the inline errors; fill everything in and the
collected values appear below the buttons.
Source: Markdown
```aardvark
{% ContactForm %}
```
Source: snippet
```jsx
import { forwardRef, useState } from 'react';
import { useForm } from '@mantine/form';
import { Button, Group, Stack, TextInput } from '@mantine/core';
const ContactForm = forwardRef(function ContactForm(props, ref) {
const form = useForm({
initialValues: { name: '', email: '', message: '' },
validate: {
email: (value) => (/^\S+@\S+\.\S+$/.test(value) ? null : 'Enter a valid email address'),
},
});
return (