Command palette

@yasinsensoy/native

React Native · Components

Form

Form: collects field values, validates them with a schema and distributes errors to fields.

57 exports

Import

import {
  FieldArray,
  Form,
  SubmitButton,
  SchemaForm,
  useFieldArray,
  readFormDraft,
  clearFormDraft,
  useForm,
  useFormValue,
  useFormPending,
  useFormField,
  translateText,
  humanizeValue,
  localizeOptions,
  localizeField,
  localizeSection,
  parseFieldName,
  formatFieldName,
  getIn,
  humanizeName,
  deriveFromJsonSchema,
  toJsonSchema,
  deriveFields,
  isFieldVisible,
  issuesToErrors,
  validateValues,
} from "@yasinsensoy/native";

Form

component

Form: collects field values, validates them with a schema and distributes errors to fields. Same API and the same rules as Form on web; values are kept in memory by field name instead of an HTML form. Each field subscribes only to its own name, so in long forms other fields do not re-render while typing.

Giving name to the fields inside (TextField, NumberInput, Select, Checkbox, DatePicker… all of them) is enough: the value, error, required (*) and disabled state come from the form. Submitting is done with SubmitButton or submit() on the ref.

Form({ ref, schema, onValidSubmit, defaultValues, onValuesChange, draft, onDraftRestore, onValidationError, state, loading: loadingProp, submitLoading, errorDisplay, disabled, children, style, testID, }: FormProps<Schema>): JSX.Element

Examples

const SignUp = z.object({ name: z.string().min(2), age: z.number().min(18), terms: z.literal(true) });

<Form schema={SignUp} defaultValues={{ name: "" }} onValidSubmit={async (data) => api.signUp(data)}>
  <TextField name="name" label="Name" />
  <NumberInput name="age" label="Age" />
  <Checkbox name="terms" label="I accept the terms" />
  <SubmitButton>Sign up</SubmitButton>
</Form>

FieldArray

component

Repeated form rows with a ready-made look: title, rows, delete/duplicate buttons, reordering by dragging the handle, add button, empty state and the array's error. Same API as FieldArray on web; the logic is useFieldArray.

  • When a row is added its first field is focused; adding and deleting are announced.
  • min/max lock the buttons automatically.
  • sortable: drag the handle; move up/down with a screen reader.
FieldArray({ name, defaultValue, emptyItem, min, max, focusOnAdd, label, description, children, sortable, removable, duplicable, addLabel, footer, empty, rowLabel, rowVariant, rowStyle, disabled: disabledProp, style, }: FieldArrayProps<T>): JSX.Element

Examples

<Form schema={Invoice} defaultValues={{ items: [{ name: "Item", quantity: 2 }] }} onValidSubmit={save}>
  <FieldArray name="items" label="Items" emptyItem={{ quantity: 1 }} sortable duplicable max={20}>
    {(row) => (
      <>
        <TextField label="Product" name={row.name("name")} />
        <NumberInput label="Quantity" name={row.name("quantity")} />
      </>
    )}
  </FieldArray>
  <SubmitButton>Save</SubmitButton>
</Form>

SubmitButton

component

Button that submits the form: validates and submits when pressed; shows loading while submitting. Inactive while the form is loading or disabled.

SubmitButton({ loading, disabled, onPress, ...props }: SubmitButtonProps): JSX.Element

Examples

<SubmitButton block>Save</SubmitButton>

SchemaForm

component

Generates a form from a schema or a JSON definition: fields, labels, required marks, validation and sections in one component. The same definition format as SchemaForm on web (FormFieldConfig); the same JSON definition works on both platforms.

  • Types: text, email, password, url, textarea, number, select, multiselect, autocomplete, radio, checkbox, switch, date, datetime, daterange, time, file, slider, rating, tags, otp, array, hidden. New types are added with components.
  • Conditional fields with when: { field: "type", equals: "corporate" }.
  • Titled sections with sections, a step-by-step wizard with steps; multiple columns on a tablet with columns.
  • Mobile: the right keyboard for email/URL fields, auto-capitalization off.
SchemaForm({ schema, fields: fieldList, sections, steps, wizard, columns, translate, i18nPrefix, submitLabel, resetLabel, hideSubmit, components, children, defaultValues, style, ...props }: SchemaFormProps<Schema>): JSX.Element

Examples

<SchemaForm schema={Profile} draft="profile" onValidSubmit={save}
  fields={["name", "email", { name: "role", type: "radio" }, "newsletter"]} />

Repeated rows inside a Form (invoice items, phone numbers, education history): add, delete, move, duplicate. Same API as useFieldArray on web. Values live in the form's store as an array; when rows are reordered, what was typed moves with the row.

For a ready-made look see FieldArray; this hook is for your own layout.

useFieldArray(options: UseFieldArrayOptions<T>): FieldArrayApi<T>

Examples

const items = useFieldArray({ name: "items", emptyItem: { quantity: 1 }, min: 1 });
{items.fields.map((row) => (
  <View key={row.key}>
    <TextField label="Product" name={row.name("name")} />
    <NumberInput label="Quantity" name={row.name("quantity")} />
  </View>
))}
<Button onPress={() => items.append()}>Add item</Button>

Reads a stored draft (e.g. to show "draft available" in a list).

readFormDraft(key: string, options?: Pick<FormDraftOptions, "storage" | "maxAge">): Record<string, unknown> | null

Deletes a stored draft.

clearFormDraft(key: string, options?: Pick<FormDraftOptions, "storage">): void

useForm

function

To control the enclosing Form from code (e.g. a "Save" button in the screen header). Returns null outside a form.

useForm(): FormHandle | null

Examples

function SaveButton() {
  const form = useForm();
  return <Button onPress={() => form?.submit()}>Save</Button>;
}

useFormValue

function

Watches the value of a field in the form; re-renders when it changes (e.g. to show another field based on a choice). Without a name all values are returned.

useFormValue(name?: string): T | undefined

Examples

const type = useFormValue("type");
{type === "company" ? <TextField name="taxId" label="Tax ID" /> : null}

Whether the form is submitting. false outside a form.

useFormPending(): boolean

useFormField

function

To bind your own field component to the form: value, error, required and disabled state. All built-in fields use it. Returns null outside a form or without a name.

useFormField(name: string | undefined, options?: { defaultValue?: T; focus?: () => void; sensitive?: boolean; }): FormFieldState<T> | null

Examples

function ColorField({ name }: { name: string }) {
  const field = useFormField<string>(name);
  return <ColorInput value={field?.value} onChange={field?.setValue} error={field?.error} />;
}

Returns the translation if the text is a dictionary key, otherwise the text itself ("login.title" → "Sign in"; "Full name" → "Full name").

translateText(text: T, t: FormTranslator | undefined): T | string

Generates a readable label from an option value: "istanbul" → "Istanbul", "corporateAccount" → "Corporate account". Values starting with an uppercase letter ("TR") or containing digits or dots stay as they are.

humanizeValue(value: string): string

Display labels of options. Order: a label that is a dictionary key → prefix.field.options.value → optionsKey.value → label → label generated from the value.

localizeOptions(field: Pick<FormFieldConfig, "name" | "options" | "optionsKey">, t?: FormTranslator, { prefix }?: LocalizeOptions): Exclude<FormFieldOption, string>[] | undefined

Translates the texts of a field definition (label, description, tooltip, placeholder, options) from the dictionary. Text without a dictionary entry stays as is, so the schema can contain both plain text and keys.

localizeField(field: FormFieldConfig, t?: FormTranslator, options?: LocalizeOptions): FormFieldConfig

Examples

const t = await i18n.getT("en");
localizeField({ name: "city", label: "form.city", options: ["istanbul"] }, t);
// { name: "city", label: "City", options: [{ value: "istanbul", label: "Istanbul" }] }

Translates the title and description of a section or step.

localizeSection(section: S, t?: FormTranslator): S

Converts a field name to a path: "address.city" → ["address", "city"], "items[0].name" → ["items", 0, "name"], "tags[]" → ["tags", undefined].

parseFieldName(name: string): Segment[]

Converts a path to a field name: ["items", 0, "name"] → "items[0].name".

formatFieldName(path: ReadonlyArray<PropertyKey | { key: PropertyKey; }>): string

getIn

function

Reads a value from an object by field name: getIn(values, "address.city").

getIn(source: unknown, name: string): unknown

humanizeName

function

Generates a label from a name: "birthDate" → "Birth date", "address.city" → "City".

humanizeName(name: string): string

Derives field definitions from a JSON Schema. Objects are flattened with parent.child names; property order is preserved.

deriveFromJsonSchema(schema: JsonSchema, root?: JsonSchema, prefix?: string): FormFieldConfig[]

toJsonSchema

function

Returns the schema's JSON Schema (via Standard JSON Schema; otherwise null). Computed once per schema.

toJsonSchema(schema: StandardSchemaV1 | null | undefined): JsonSchema | null

deriveFields

function

Derives field definitions from a schema (one that offers Standard JSON Schema, such as Zod 4.2+). The label comes from title (.meta({ title })), the description from description (.describe()), field settings from .meta({ ui: { … } }).

Derivation rules:

  • string → text; email/url/date/time formats map to their own type; maxLength > 200 → textarea.
  • enum → radio with 3 or fewer options, otherwise select.
  • number → number (min/max); no decimals for integers.
  • boolean → checkbox; z.literal(true) is a required checkbox.
  • enum array → multiselect, string array → tags, object array → array (row fields in fields; add, remove, drag to reorder).
  • object → its fields named parent.child.
deriveFields(schema: StandardSchemaV1): FormFieldConfig[]

Examples

const Schema = z.object({
  name: z.string().min(2).meta({ title: "Full name" }),
  about: z.string().max(500).optional().meta({ ui: { type: "textarea", props: { rows: 4 } } }),
  role: z.enum(["admin", "editor", "reader"]),
});
deriveFields(Schema); // [{ name: "name", type: "text", label: "Full name", required: true, … }, …]

Does the field's condition match?

isFieldVisible(field: FormFieldConfig, values: Record<string, unknown>): boolean

Converts Standard Schema issues into errors by field name. An error on an array item (e.g. tags[2]) is also written under the array's own name (tags), so arrays shown as a single field also show the error.

issuesToErrors(issues: ReadonlyArray<StandardSchemaV1.Issue>): {
    errors: FormErrors

Validates values with a schema. Returns synchronously for sync schemas and a Promise for async ones.

validateValues(schema: Schema, values: unknown): FormValidation<StandardSchemaV1.InferOutput<Schema>> | Promise<FormValidation<StandardSchemaV1.InferOutput<Schema>>>

Options of useFieldArray.

NameTypeDefaultDescription
namestringField name of the array ("items"). Names of the fields in rows are generated with row.name("name") as items[0].name; schema errors come with the same name. For nested arrays use row.name("options").
defaultValue?readonly T[]Initial rows. Defaults to the array in the form's defaultValues.
emptyItem?T | (() => T){}Initial value of a new row (e.g. { quantity: 1 }); a function is called on every add. Give "" for single-value rows (tags[0]).
min?number0Minimum rows; empty rows are added if there are fewer initially, and it cannot be deleted below this.
max?numberMaximum rows; no adding when full.
focusOnAdd?booleantrueFocuses the first field in a row when it is added.

FieldArrayRow

interface

An item of useFieldArray fields: one row.

NameTypeDescription
keystringThe row's stable key; pass it as key (not the index).
indexnumberIts current index (from 0).
name(path?: string) => stringName of a field in the row: row.name("name") → "items[0].name". Without an argument, the row's own name ("items[0]").
valueT | undefinedThe row's current value.
errorstring | undefinedError belonging to the row itself (e.g. the row object's refine).

Add options of useFieldArray.

NameTypeDefaultDescription
focus?booleanfocusOnAddFocus the first field of the new row.

FieldArrayApi

interface

Result of useFieldArray.

NameTypeDescription
namestringName of the array.
fieldsFieldArrayRow<T>[]Rows, in order.
lengthnumberRow count.
append(value?: T, options?: FieldArrayAddOptions) => voidAdds a row at the end. Uses emptyItem if no value is given.
prepend(value?: T, options?: FieldArrayAddOptions) => voidAdds a row at the start.
insert(index: number, value?: T, options?: FieldArrayAddOptions) => voidAdds a row at index index.
remove(index: number | readonly number[]) => voidDeletes the row (or rows); does not go below min.
move(from: number, to: number) => voidMoves a row from from to to; the values go with the row.
swap(a: number, b: number) => voidSwaps two rows.
duplicate(index: number, options?: FieldArrayAddOptions) => voidCopies a row with its current values right below it.
replace(values: readonly T[]) => voidReplaces all rows with the given ones.
getValues() => T[]Current values of the rows.
canAddbooleanmax is not reached.
canRemovebooleanAbove min.
errorstring | undefinedError belonging to the array itself (e.g. "Add at least one item").

Props of the FieldArray component.

NameTypeDefaultDescription
label?ReactNodeGroup title.
description?ReactNodeDescription below the title.
children(row: FieldArrayRow<T>, array: FieldArrayApi<T>) => ReactNodeThe fields of one row. Give names with row.name("name").
sortable?booleanRows are reordered by dragging the handle. See SortableList.
removable?booleantrueRow delete button.
duplicable?booleanButton that copies a row with its values.
addLabel?ReactNode"Ekle"Add button text.
footer?false | ((array: FieldArrayApi<T>) => ReactNode)Your own footer instead of the add button; hidden with false.
empty?ReactNode"Henüz satır yok"When there are no rows.
rowLabel?(row: FieldArrayRow<T>) => string"{sıra}. satır"Readable name of a row (in the delete button, announcements).
rowVariant?"card" | "plain""card"Row look: card a bordered box, plain only rows.
rowStyle?StyleProp<ViewStyle>Style of the row box.
disabled?booleanDisables everything.
style?StyleProp<ViewStyle>Container style.
namestringField name of the array ("items"). Names of the fields in rows are generated with row.name("name") as items[0].name; schema errors come with the same name. For nested arrays use row.name("options").
defaultValue?readonly T[]Initial rows. Defaults to the array in the form's defaultValues.
emptyItem?T | (() => T){}Initial value of a new row (e.g. { quantity: 1 }); a function is called on every add. Give "" for single-value rows (tags[0]).
min?number0Minimum rows; empty rows are added if there are fewer initially, and it cannot be deleted below this.
max?numberMaximum rows; no adding when full.
focusOnAdd?booleantrueFocuses the first field in a row when it is added.

FormState

interface

Form state returned by the server (or your own code). Only errors and formErrors are read. The same shape as FormState on web; the same API response can be passed directly on both platforms.

NameTypeDescription
errors?Record<string, string | readonly string[] | undefined> | null | undefinedError messages by field name (name). With an array the first message is shown (compatible with Zod's flatten().fieldErrors shape).
formErrors?readonly string[] | null | undefinedErrors belonging to no field; shown in a box above the form.

Where the draft is stored. createStorage() (@yasinsensoy/native/storage) can be passed directly; for another store providing these three methods is enough.

NameTypeDescription
get(key: string): unknownReads an entry.
set(key: string, value: never): voidWrites an entry (a JSON-serializable value).
remove(key: string): voidDeletes an entry.

Form draft options.

NameTypeDefaultDescription
keystringStorage key; must be unique for each form with a draft.
storage?FormDraftStorageWhere to store it. If omitted it is kept in memory while the app stays open (it comes back when the screen is closed and reopened). Pass createStorage() so it survives the app closing.
exclude?readonly string[]Field names not to write to the draft. Password, file and signature fields are never written.
maxAge?number7 daysA draft older than this is not restored (milliseconds).

How the Form looks while loading (same as web).

  • skeleton: fields and labels turn into muted boxes in the same place and size; nothing shifts when the data arrives.
  • disabled: all fields and buttons are disabled.
  • overlay: a semi-transparent scrim that blocks touches covers the form, with a spinner in the middle.
type FormLoadingMode = "skeleton" | "disabled" | "overlay"

Detailed options of FormProps.loading.

NameTypeDefaultDescription
mode?FormLoadingMode"skeleton"Look. See FormLoadingMode.
text?ReactNodeoverlay: text next to the spinner.
animation?SkeletonAnimation"pulse"skeleton: animation of the boxes.
delay?number0overlay: delay before the scrim appears (ms).

Detailed options of FormProps.submitLoading.

NameTypeDefaultDescription
mode?"disabled" | "overlay""disabled"Look.
text?ReactNodeoverlay: text next to the spinner (e.g. "Saving…").
delay?number150overlay: delay before the scrim appears (ms).

FormHandle

interface

The Form ref and the useForm result: controls the form from code.

NameTypeDescription
submit(): Promise<boolean>Validates and calls onValidSubmit if valid. If invalid, focuses the first invalid field. Returns true if submitted.
reset(values?: Partial<Values> | Record<string, unknown>): voidResets the values to the initial ones (or the given ones), clears errors and the draft.
getValues(): Record<string, unknown>Current values (a nested object).
getValue(name: string): unknownValue of a field.
setValue(name: string, value: unknown): voidChanges the value of a field.
setErrors(errors: FormState["errors"]): voidSets external errors on fields (e.g. a server response). Cleared when the user changes the field.
focus(name: string): voidFocuses a field.
pendingbooleanWhether a submit is in progress.

FormProps

interface

Props of the Form component.

NameTypeDefaultDescription
ref?Ref<FormHandle<FormValues<Schema>>>Control from code. See FormHandle.
schema?SchemaValidation schema: Zod, Valibot, ArkType… (any library supporting Standard Schema). No extra package needed. The same rules as web: - Fields validate as you type; the message shows below the field when the user leaves it or tries to submit. - If invalid it is not submitted and the first invalid field is focused. - An error is matched to a field by its name (name) and the schema path: address.city, items[0].name. Errors without a field show above the form. - If the schema provides Standard JSON Schema (Zod 4.2+), * is added to the labels of required fields automatically. - Async schemas are supported. On native values already have their types (a number field is a number, a checkbox a boolean); no conversion is needed.
onValidSubmit?(data: FormValues<Schema>, values: Record<string, unknown>) => unknownCalled when the schema passes; data is the schema's output (typed). If async, the SubmitButton shows loading until it finishes. If it throws, the input is kept and the message is shown above the form.
defaultValues?Partial<StandardSchemaV1.InferInput<Schema>> | Record<string, unknown>Initial values of the fields, by field name ({ name: "Jane", address: { city: "Izmir" } }). A defaultValue given to the field itself wins.
onValuesChange?(values: Record<string, unknown>, name: string | null) => voidCalled on every value change (while typing).
draft?string | FormDraftOptionsStores the input as a draft; it comes back when the screen is closed and reopened (and even when the app closes if a storage is given). Deleted on a successful submit and on reset. A string is the storage key. See FormDraftOptions.
onDraftRestore?(values: Record<string, unknown>) => voidCalled when a draft is restored (e.g. for a "Draft restored" toast).
onValidationError?(errors: FormErrors, formErrors: string[]) => voidTo see schema errors before they are distributed to the fields.
state?FormState | nullState returned by the server. errors are distributed to fields by name, formErrors are shown above the form. See FormState.
loading?boolean | FormLoadingMode | FormLoadingOptionsShows the form as loading: true or "skeleton" turns fields into muted boxes, "disabled" disables them all, "overlay" puts a scrim over it that blocks touches. When skeleton ends, the defaultValues given at that moment are applied to the fields (if the user typed nothing).
submitLoading?boolean | "disabled" | "overlay" | FormSubmitLoadingOptionsfalse` (only the {@link SubmitButton} shows loading)Look of the form while submitting (while an async onValidSubmit runs): "disabled" (or true) disables the fields, "overlay" puts a scrim. If loading is given, it wins.
errorDisplay?ErrorDisplay"message"Error display style of all fields in the form. A field's own errorDisplay overrides it. See ErrorDisplay.
disabled?booleanDisables all fields.
children?ReactNodeFields, buttons.
style?StyleProp<ViewStyle>Container style.
testID?stringTest id.

Props of SubmitButton: the same as Button.

type SubmitButtonProps = ButtonProps

Built-in field types.

type FormFieldType = "text" | "email" | "password" | "url" | "search" | "textarea" | "number" | "select" | "multiselect" | "autocomplete" | "radio" | "checkbox" | "switch" | "date" | "datetime" | "daterange" | "time" | "file" | "slider" | "rating" | "tags" | "otp" | "color" | "richtext" | "phone" | "country" | "array" | "hidden"

Translator: the result of useT or i18n.getT() (t and t.has).

NameTypeDescription
has(key: string): booleanWhether the key exists in the dictionary.

Standard Schema interface (v1). Schemas from libraries such as Zod, Valibot and ArkType satisfy it out of the box.

Translation options.

NameTypeDescription
prefix?stringDictionary root for field texts. With "forms.signup", these keys are looked up for the city field: - forms.signup.city (label when it is a string) or forms.signup.city.label - forms.signup.city.description, .placeholder, .tooltip - forms.signup.city.options.istanbul (option label)

Option: a string or { value, label }.

type FormFieldOption = string | { /** Submitted value. */ value: string; /** Display name. */ label?: string; /** Description shown below. */ description?: string; /** Not selectable. */ disabled?: boolean; }

How a field error is shown. Set with the field's errorDisplay prop, Form errorDisplay and UIProvider errorDisplay; the nearest one wins.

  • "message": the message is written below the field (classic). When an error appears the field grows by one line; elements below shift.
  • "reserve": the message is still below, but one line of space is reserved up front; nothing shifts when an error appears (the field grows for messages longer than two lines).
  • "icon": a red ⓘ icon appears left of the label and the message shows in a tooltip (on hover, on field focus, or on tap on mobile). The field size never changes. Screen readers still read the message as the field's description (aria-describedby).
  • "icon-end": like "icon", with the icon right of the label.
type ErrorDisplay = "message" | "reserve" | "icon" | "icon-end"

Condition for showing the field (can be written as JSON). When several keys are given, all of them must match.

NameTypeDescription
fieldstringName of the field to look at.
equals?unknownVisible when the value equals this.
notEquals?unknownVisible when the value does not equal this.
in?readonly unknown[]Visible when the value is one of these.
filled?booleantrue: visible when the field is filled, false: when it is empty.

Definition of a single form field. Definitions without functions can be stored as JSON and sent from the server.

NameTypeDefaultDescription
namestringField name; may be nested ("address.city").
type?FormFieldType | (string & {})"text"Field type. Not needed when it can be derived from the schema.
label?stringLabel. Defaults to the schema's title or text generated from the name. If it is a dictionary key ("login.email") its translation is shown and updated when the language changes; otherwise it is shown as is.
description?stringHelp text. Defaults to the schema's description.
tooltip?stringⓘ tooltip next to the label.
placeholder?stringPlaceholder.
required?booleanRequired (asterisk on the label, browser validation).
disabled?booleanDisabled.
options?readonly FormFieldOption[]Options (select, multiselect, radio, autocomplete, tags). An option without a label gets one generated from its value ("newYork" → "New york"); a label that is a dictionary key is translated.
optionsKey?stringDictionary root for option labels: with "cities", the label of the istanbul option comes from the cities.istanbul key. Useful for translating the same list in many forms.
min?number | stringMinimum value (number, slider, date).
max?number | stringMaximum value.
step?numberStep.
minLength?numberMinimum characters.
maxLength?numberMaximum characters.
defaultValue?unknownInitial value (can also be given with Form defaultValues).
span?number | "full"1How many grid columns it spans (when columns > 1). "full" spans the row. On narrow screens every field is full width.
when?FormFieldCondition | readonly FormFieldCondition[] | ((values: Record<string, unknown>) => boolean)Visible (and submitted) only when the condition matches.
props?Record<string, unknown>Extra props passed as is to the field component (e.g. { rows: 5 }).
hidden?booleanHide (to not show a field coming from the schema).
fields?readonly FormFieldConfig[]Fields of a row for the array type; names are relative to the row ("name", "address.city"). Rows are added, removed and reordered by dragging with FieldArray (disable with props: { sortable: false }). min/max limit the row count. Derived automatically from an array of objects in the schema (z.array(z.object(...))).
columns?numberColumn count of the row fields for the array type (single column on narrow screens).

Standard JSON Schema converter.

NameTypeDescription
input(options: { /** Target version. */ readonly target: string; /** Library-specific options. */ readonly libraryOptions?: Record<string, unknown>; }) => Record<string, unknown>JSON Schema of the input side of the schema.

Value type produced by a form schema.

type FormValues = Schema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Schema> : Record<string, unknown>

Error messages by field name (name). Same shape as FormState errors; can be returned directly from a server action.

type FormErrors = Record<string, string[]>

Result of validateForm.

NameTypeDescription
successtrue | falseValues are valid.
data?Output | undefinedValue returned by the schema (transformed, typed).
errors?undefined | FormErrorsEmpty on success.
formErrors?undefined | string[]Empty on success.

FormSection

interface

Field group: a titled section or a wizard step.

NameTypeDescription
title?stringSection title (step name in a wizard).
description?stringDescription.
fieldsreadonly (string | FormFieldConfig)[]Fields of the section: a name (from the schema) or a definition.
columns?numberColumn count in this section.
optional?booleanOptional step in a wizard (Skip button).

Field settings that can be written into the schema with .meta({ ui: … }).

type FormFieldMeta = Partial<Omit<FormFieldConfig, "name" | "when">>

Simplified JSON Schema node.

NameTypeDescription
type?string | string[]Type ("string", "number"…) or a list of types.
properties?Record<string, JsonSchema>Object properties.
required?string[]Required property names.
items?JsonSchemaSchema of the array items.
prefixItems?JsonSchema[]Tuple items.
anyOf?JsonSchema[]At least one of the options.
oneOf?JsonSchema[]Exactly one of the options.
allOf?JsonSchema[]All of them at once.
enum?unknown[]Allowed values.
const?unknownThe single allowed value.
$ref?stringReference to another definition.
$defs?Record<string, JsonSchema>Definitions.
definitions?Record<string, JsonSchema>Definitions (old name).
default?unknownDefault value.

Custom field renderer: takes the definition and returns the field.

type FormFieldRenderer = (field: FormFieldConfig & { label: string; }) => ReactNode

Props of the SchemaForm component.

NameTypeDefaultDescription
fields?readonly (string | FormFieldConfig)[]Fields and their order. With a name the definition is derived from the schema; with a definition it is written over the derived one ({ name: "role", type: "radio" }). If omitted all fields in the schema are shown in order.
sections?readonly FormSection[]Splits fields into titled sections (instead of fields).
steps?readonly FormSection[]Splits fields into wizard steps: each section becomes a Wizard step, and that step is validated with the schema when moving forward.
wizard?Omit<WizardProps<Schema>, "steps" | "schema" | "onComplete" | "defaultValues" | "draft" | "state">Extra props passed to the Wizard when a wizard is used.
columns?1 | 2 | 3 | 41Column count on wide screens (tablet, landscape); always a single column on a phone in portrait.
translate?FormTranslatorFunction that translates texts (t and t.has). Labels, descriptions, placeholders, option names and section titles are translated if they are a key in the dictionary.
i18nPrefix?stringDictionary root of the field texts ("forms.signup" → forms.signup.city.label).
submitLabel?ReactNode"Gönder"Submit button text.
resetLabel?ReactNode | trueReset button: true with the default text, a string with that text.
hideSubmit?booleanHide the submit button (if you put your own button in children).
components?Partial<Record<string, FormFieldRenderer>>Custom field renderers by type ({ iban: (f) => <TextField {...f} mask="iban" /> }).
children?ReactNodeShown after the fields, before the buttons.
ref?Ref<FormHandle<FormValues<Schema>>>Control from code. See FormHandle.
schema?SchemaValidation schema: Zod, Valibot, ArkType… (any library supporting Standard Schema). No extra package needed. The same rules as web: - Fields validate as you type; the message shows below the field when the user leaves it or tries to submit. - If invalid it is not submitted and the first invalid field is focused. - An error is matched to a field by its name (name) and the schema path: address.city, items[0].name. Errors without a field show above the form. - If the schema provides Standard JSON Schema (Zod 4.2+), * is added to the labels of required fields automatically. - Async schemas are supported. On native values already have their types (a number field is a number, a checkbox a boolean); no conversion is needed.
onValidSubmit?(data: FormValues<Schema>, values: Record<string, unknown>) => unknownCalled when the schema passes; data is the schema's output (typed). If async, the SubmitButton shows loading until it finishes. If it throws, the input is kept and the message is shown above the form.
defaultValues?Partial<StandardSchemaV1.InferInput<Schema>> | Record<string, unknown>Initial values of the fields, by field name ({ name: "Jane", address: { city: "Izmir" } }). A defaultValue given to the field itself wins.
onValuesChange?(values: Record<string, unknown>, name: string | null) => voidCalled on every value change (while typing).
draft?string | FormDraftOptionsStores the input as a draft; it comes back when the screen is closed and reopened (and even when the app closes if a storage is given). Deleted on a successful submit and on reset. A string is the storage key. See FormDraftOptions.
onDraftRestore?(values: Record<string, unknown>) => voidCalled when a draft is restored (e.g. for a "Draft restored" toast).
onValidationError?(errors: FormErrors, formErrors: string[]) => voidTo see schema errors before they are distributed to the fields.
state?FormState | nullState returned by the server. errors are distributed to fields by name, formErrors are shown above the form. See FormState.
loading?boolean | FormLoadingMode | FormLoadingOptionsShows the form as loading: true or "skeleton" turns fields into muted boxes, "disabled" disables them all, "overlay" puts a scrim over it that blocks touches. When skeleton ends, the defaultValues given at that moment are applied to the fields (if the user typed nothing).
submitLoading?boolean | "disabled" | "overlay" | FormSubmitLoadingOptionsfalse` (only the {@link SubmitButton} shows loading)Look of the form while submitting (while an async onValidSubmit runs): "disabled" (or true) disables the fields, "overlay" puts a scrim. If loading is given, it wins.
errorDisplay?ErrorDisplay"message"Error display style of all fields in the form. A field's own errorDisplay overrides it. See ErrorDisplay.
disabled?booleanDisables all fields.
style?StyleProp<ViewStyle>Container style.
testID?stringTest id.