# FormState (@salmonui/inputs/form/state)

> The FormState interface of @salmonui/inputs/form/state: What useFormState() returns.

Canonical: https://salmonui.dev/docs/reference/inputs/form-state/FormState

```ts
import type { FormState } from '@salmonui/inputs/form/state';
```

Entry index: https://salmonui.dev/docs/reference/inputs/form-state (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/inputs/form-state.md).

## Reference

Kind: interface

```ts
interface FormState {
    readonly ref: (form: HTMLFormElement | null) => (() => void) | undefined;
    readonly isDirty: boolean;
    readonly dirtyFields: readonly string[];
    readonly isFieldDirty: (name: string) => boolean;
    readonly reset: () => void;
}
```

What `useFormState()` returns.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ref` | `readonly ref: (form: HTMLFormElement \| null) => (() => void) \| undefined;` |  | Attach to the `<form>` (`<Form ref={state.ref}>`); its values on mount are the initial values. |
| `isDirty` | `readonly isDirty: boolean;` |  | True while any field differs from its initial value. |
| `dirtyFields` | `readonly dirtyFields: readonly string[];` |  | Names of the fields whose values differ from the initial ones, in form order. |
| `isFieldDirty` | `readonly isFieldDirty: (name: string) => boolean;` |  | Whether the field `name` differs from its initial value. |
| `reset` | `readonly reset: () => void;` |  | Resets the form (`form.reset()`): every field returns to its `defaultValue`, and the state is clean again. |
