Skip to main content

Usage

The main exported component is NvsDynamicForm.

Minimal example

import React from 'react';
import { NvsDynamicForm } from '@nvs-dynamic-form/react-core';

export function Example() {
return (
<NvsDynamicForm
fields={[]}
formElements={{}}
buttonComponent={(props) => <button {...props} />}
submitButtonDefaultOptions={{
label: 'Submit',
isFullWidth: false,
position: 'right',
}}
onSubmit={async (values) => {
console.log(values);
}}
/>
);
}

Props

NvsDynamicForm props (from INvsDynamicForm):

PropTypeNotes
onSubmit(values: unknown) => void | Promise<void>Submit callback (sync or async).
fieldsArray<FieldBase | GroupField | ArrayField>Form structure definition.
formClassstringOptional className for the underlying <form>.
formElementsRecord<string, { component: React.FC<any>; class: typeof FieldBase }>Registry that maps fieldType → renderer + field model class.
containerReact.FC<any>Optional container component for wrapping the form or groups.
containerOptionsRecord<string, any>Props/options forwarded to the container implementation.
containerVisiblebooleanWhen true, wraps the whole form with container (unless useContainersOutsideGroup).
useContainersOutsideGroupbooleanControls container usage for nested group/array layouts.
useGroupContainerbooleanEnables group container behavior in the builder.
buttonComponentReact.FC<any>Submit/add/remove buttons are rendered via this component.
submitButtonDefaultOptionsISubmitButtonDefaultOptionsDefault submit button config (label, position, full width).
submitButtonOptionsRecord<string, any>Extra props forwarded to the submit button component.
submitButtonVisiblebooleanShow/hide submit button.
submitButtonLabelstringSubmit button label override.
submitButtonPosition'left' | 'center' | 'right'Submit button alignment.
submitButtonIsFullWidthbooleanFull-width submit button.
submitButtonContainerClassstringClass name for submit button container wrapper.
addButtonDefaultOptionsArrayFieldAddButtonDefault options for ArrayField add button.
removeButtonDefaultOptionsArrayFieldRemoveButtonDefault options for ArrayField remove button.
labelDefaultOptionsLabelOptionsDefault label options used by internal field/label components.
doubleSubmitProtectionbooleanPrevents double submit while a submit is in progress.
note

The exact shape of field definitions and default options is exported from the package under types.

Examples

The package repo includes Storybook stories for many configurations.

In these docs, each example lives on its own page under Examples:

  • DynamicForm wrapper (recommended starting point)
  • Input + Textarea (minimal setup)
  • GroupField
  • ArrayField