View as Markdown

API reference: @salmonui/inputs/form

Formcomponent

import { Form } from '@salmonui/inputs/form';
function Form(props: FormProps): ReactNode;

A native <form> that validates its Salmon fields on submit. Native submission, FormData, useFormStatus and React 19 actions work unchanged. ref is the <form>.

Props: FormProps

Form props (9)
NameSignatureDescription
childrenoptionalreadonly children?: ReactNode;
refoptionalreadonly ref?: Ref<HTMLFormElement> | undefined;
actionoptionalreadonly action?: string | ((formData: FormData) => void | Promise<void>) | undefined;

A URL or a React 19 action (useActionState).

validationBehavioroptionalreadonly validationBehavior?: ValidationBehavior | undefined;

'native' (default) blocks an invalid submit and focuses the first invalid field; 'aria' marks fields and submits.

validateOnoptionalreadonly validateOn?: ValidateOn | undefined;

Default validateOn of the fields inside. Default 'blur'.

validationErrorsoptionalreadonly validationErrors?: ValidationErrors | undefined;

Server errors keyed by field name, shown until the field's value changes.

onBeforeValidateoptionalreadonly onBeforeValidate?: ((event: FormValidateEvent) => void) | undefined;
onValidateoptionalreadonly onValidate?: ((result: FormValidationResult) => void) | undefined;
requiredMarkoptionalreadonly requiredMark?: boolean | undefined;

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}.