# @salmonui/inputs/form-renderer API reference

> 12 exported symbols of @salmonui/inputs/form-renderer: 1 component, 6 interfaces and 5 types.

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

```ts
import { … } from '@salmonui/inputs/form-renderer';
```

## Components

### FormRenderer

Kind: component

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormRenderer

```ts
function FormRenderer(props: FormRendererProps): ReactNode;
```

A form rendered from a JSON Schema subset and a UI schema:
Salmon fields inside `Form`, laid out in rows and
columns, validated by the shared rule compiler, submitted as typed data.
Fields are uncontrolled; the renderer re-renders only when its props change.

Props: [`FormRendererProps`](https://salmonui.dev/docs/reference/inputs/form-renderer/FormRendererProps) (its members are the props)

## Interfaces

### FormRendererProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormRendererProps

```ts
interface FormRendererProps extends Omit<FormProps, 'onSubmit' | 'children'> {
    readonly schema: FormSchema;
    readonly uiSchema?: FormUiSchema | undefined;
    readonly onSubmit?: ((data: FormRendererData, details: FormRendererSubmitDetails, event: SubmitEvent<HTMLFormElement> | null) => void) | undefined;
    readonly children?: ReactNode;
    readonly size?: FieldSize | undefined;
    readonly localeText?: FormRendererLocaleText | undefined;
}
```

Members (14):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `schema` | `readonly schema: FormSchema;` |  | JSON Schema subset. |
| `uiSchema` | `readonly uiSchema?: FormUiSchema \| undefined;` | optional | Layout and widget choices. |
| `onSubmit` | `readonly onSubmit?: ((data: FormRendererData, details: FormRendererSubmitDetails, event: SubmitEvent<HTMLFormElement> \| null) => void) \| undefined;` | optional | Every submit, valid or not, with the data typed by the schema. The native submit is prevented unless `action` is set. |
| `children` | `readonly children?: ReactNode;` | optional | Rendered after the fields, before the submit button. |
| `size` | `readonly size?: FieldSize \| undefined;` | optional | Metric set of every field and the submit button. Default `'md'`. |
| `localeText` | `readonly localeText?: FormRendererLocaleText \| undefined;` | optional |  |
| `ref` | `ref?: Ref<HTMLFormElement>;` | optional, inherited |  |
| `action` | `action?: string \| ((formData: FormData) => void \| Promise<void>);` | optional, inherited | A URL or a React 19 action (`useActionState`). |
| `validationBehavior` | `validationBehavior?: ValidationBehavior;` | optional, inherited | `'native'` (default) blocks an invalid submit and focuses the first invalid field; `'aria'` marks fields and submits. |
| `validateOn` | `validateOn?: ValidateOn;` | optional, inherited | Default `validateOn` of the fields inside. Default `'blur'`. |
| `validationErrors` | `validationErrors?: Readonly<Record<string, string \| readonly string[] \| undefined>>;` | optional, inherited | Server errors keyed by field `name`, shown until the field's value changes. |
| `onBeforeValidate` | `onBeforeValidate?: ((event: FormValidateEvent) => void);` | optional, inherited |  |
| `onValidate` | `onValidate?: ((result: FormValidationResult) => void);` | optional, inherited |  |
| `requiredMark` | `requiredMark?: boolean;` | optional, inherited | Marks the label of every required field inside with a decorative asterisk (`@salmonui/inputs/form/styles.css`); the requirement itself is announced from `required` / `aria-required`. A `Field` opts out with `requiredMark={false}`. |

### FormRendererSubmitDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormRendererSubmitDetails

```ts
interface FormRendererSubmitDetails {
    readonly isValid: boolean;
    readonly errors: Readonly<Record<string, readonly string[]>>;
}
```

Second argument of `onSubmit`: errors keyed by property name.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `isValid` | `readonly isValid: boolean;` |  |  |
| `errors` | `readonly errors: Readonly<Record<string, readonly string[]>>;` |  |  |

### FormSchema

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormSchema

```ts
interface FormSchema {
    readonly type: 'object';
    readonly title?: string | undefined;
    readonly description?: string | undefined;
    readonly properties: Readonly<Record<string, FormSchemaProperty>>;
    readonly required?: readonly string[] | undefined;
}
```

The JSON Schema subset `FormRenderer` renders: an object of scalar properties.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `readonly type: 'object';` |  |  |
| `title` | `readonly title?: string \| undefined;` | optional | The form's accessible name when no `aria-label` / `aria-labelledby` is given. |
| `description` | `readonly description?: string \| undefined;` | optional |  |
| `properties` | `readonly properties: Readonly<Record<string, FormSchemaProperty>>;` |  |  |
| `required` | `readonly required?: readonly string[] \| undefined;` | optional |  |

### FormSchemaProperty

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormSchemaProperty

```ts
interface FormSchemaProperty {
    readonly type: FormSchemaType;
    readonly title?: string | undefined;
    readonly description?: string | undefined;
    readonly default?: FormSchemaValue | undefined;
    readonly enum?: readonly (string | number)[] | undefined;
    readonly const?: FormSchemaValue | undefined;
    readonly format?: 'email' | 'uri' | (string & {}) | undefined;
    readonly minLength?: number | undefined;
    readonly maxLength?: number | undefined;
    readonly minimum?: number | undefined;
    readonly maximum?: number | undefined;
    readonly pattern?: string | undefined;
}
```

One property of the JSON Schema subset. Other keywords are ignored.

Members (12):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `readonly type: FormSchemaType;` |  |  |
| `title` | `readonly title?: string \| undefined;` | optional | Field label; default the property name. |
| `description` | `readonly description?: string \| undefined;` | optional |  |
| `default` | `readonly default?: FormSchemaValue \| undefined;` | optional |  |
| `enum` | `readonly enum?: readonly (string \| number)[] \| undefined;` | optional | Allowed values: a `Select` (or `RadioGroup`) of these. |
| `const` | `readonly const?: FormSchemaValue \| undefined;` | optional | `true` on a boolean: the box must be checked (a required checkbox). |
| `format` | `readonly format?: 'email' \| 'uri' \| (string & {}) \| undefined;` | optional | `'email'` (email input and rule), `'uri'` (url input and rule). |
| `minLength` | `readonly minLength?: number \| undefined;` | optional |  |
| `maxLength` | `readonly maxLength?: number \| undefined;` | optional |  |
| `minimum` | `readonly minimum?: number \| undefined;` | optional |  |
| `maximum` | `readonly maximum?: number \| undefined;` | optional |  |
| `pattern` | `readonly pattern?: string \| undefined;` | optional | A regular expression source (unanchored, as in JSON Schema). |

### FormUiField

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormUiField

```ts
interface FormUiField {
    readonly widget?: FormUiWidget | undefined;
    readonly label?: ReactNode;
    readonly description?: ReactNode;
    readonly placeholder?: string | undefined;
    readonly disabled?: boolean | undefined;
    readonly readOnly?: boolean | undefined;
    readonly autoComplete?: string | undefined;
    readonly enumLabels?: readonly string[] | undefined;
}
```

Per-property UI choices.

Members (8):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `widget` | `readonly widget?: FormUiWidget \| undefined;` | optional |  |
| `label` | `readonly label?: ReactNode;` | optional | Overrides `title`. |
| `description` | `readonly description?: ReactNode;` | optional | Overrides `description`. |
| `placeholder` | `readonly placeholder?: string \| undefined;` | optional |  |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `readOnly` | `readonly readOnly?: boolean \| undefined;` | optional |  |
| `autoComplete` | `readonly autoComplete?: string \| undefined;` | optional |  |
| `enumLabels` | `readonly enumLabels?: readonly string[] \| undefined;` | optional | Option labels of an `enum`, in `enum` order. |

### FormUiSchema

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormUiSchema

```ts
interface FormUiSchema {
    readonly layout?: readonly (string | readonly string[])[] | undefined;
    readonly fields?: Readonly<Record<string, FormUiField>> | undefined;
    readonly submit?: false | {
        readonly label?: ReactNode;
        readonly tone?: ButtonTone | undefined;
        readonly variant?: ButtonVariant | undefined;
    } | undefined;
}
```

Layout and widget choices.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `layout` | `readonly layout?: readonly (string \| readonly string[])[] \| undefined;` | optional | Ordered rows: a property name, or names shown side by side as equal columns. Unlisted properties follow in schema order. |
| `fields` | `readonly fields?: Readonly<Record<string, FormUiField>> \| undefined;` | optional |  |
| `submit` | `readonly submit?: false \| {     readonly label?: ReactNode;     readonly tone?: ButtonTone \| undefined;     readonly variant?: ButtonVariant \| undefined; } \| undefined;` | optional | The submit `Button`; `false` hides it. |

## Types

### FormRendererData

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormRendererData

```ts
type FormRendererData = Record<string, FormSchemaValue | null>;
```

Submitted data, typed by the schema.

### FormRendererLocaleText

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormRendererLocaleText

```ts
type FormRendererLocaleText = FieldValidationText & {
    readonly submit?: string;
};
```

Validation strings (`validation*` keys, shared with every field) and the default submit label.

Members (18):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `validationCreditcard` | `validationCreditcard?: string;` | optional, inherited |  |
| `validationDate` | `validationDate?: string;` | optional, inherited |  |
| `validationDateIso` | `validationDateIso?: string;` | optional, inherited |  |
| `validationDigits` | `validationDigits?: string;` | optional, inherited |  |
| `validationEmail` | `validationEmail?: string;` | optional, inherited |  |
| `validationMax` | `validationMax?: string;` | optional, inherited |  |
| `validationMaxLength` | `validationMaxLength?: string;` | optional, inherited |  |
| `validationMin` | `validationMin?: string;` | optional, inherited |  |
| `validationMinLength` | `validationMinLength?: string;` | optional, inherited |  |
| `validationNumber` | `validationNumber?: string;` | optional, inherited |  |
| `validationPattern` | `validationPattern?: string;` | optional, inherited |  |
| `validationRange` | `validationRange?: string;` | optional, inherited |  |
| `validationRangeLength` | `validationRangeLength?: string;` | optional, inherited |  |
| `validationRequired` | `validationRequired?: string;` | optional, inherited |  |
| `validationTel` | `validationTel?: string;` | optional, inherited |  |
| `validationUrl` | `validationUrl?: string;` | optional, inherited |  |
| `validationValidate` | `validationValidate?: string;` | optional, inherited |  |
| `submit` | `submit?: string;` | optional, inherited |  |

### FormSchemaType

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormSchemaType

```ts
type FormSchemaType = 'string' | 'number' | 'integer' | 'boolean';
```

### FormSchemaValue

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormSchemaValue

```ts
type FormSchemaValue = string | number | boolean;
```

### FormUiWidget

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/form-renderer/FormUiWidget

```ts
type FormUiWidget = 'text' | 'password' | 'textarea' | 'number' | 'checkbox' | 'switch' | 'select' | 'radio';
```
