What's new in v7
This page lists the main features v7 adds for a v6 user, each with a link to its documentation. The breaking changes and the steps to upgrade are in the 7.x upgrade guide.
A different @rjsf/core
@rjsf/core in v7 is very different from v6's.
- It no longer renders Bootstrap 3 markup.
@rjsf/bootstrap3keeps that markup for apps that still style it; it is deprecated and will be removed in v8. See Supported themes and Bootstrap 3 markup moved from core to @rjsf/bootstrap3. - Its markup is plain and framework-neutral. Two optional stylesheets style it:
rjsf.csslays the form out andrjsf-theme.cssgives it a default look. TheclassMapprop sets or extends the class of each element core renders, so core's markup can be styled with Tailwind. See Customizing with other frameworks and classMap. Formis a function component. As in v6, it takes its data asformDataor asinitialFormData, a seed it reads on mount and then keeps its own data from, and it now readsformDataonly when you pass a new value. See Form takes its data as initialFormData or formData.
Presentation for theme builders
Before rendering a field, the form now computes its presentation plan: whether the FieldTemplate or the widget or field draws each of the label, description, help and errors, and which ids and ARIA attributes tie them to the control. A theme reads the plan instead of working out these parts itself. See Presentation.
- A theme declares a
ThemePresentation: which parts its fields and widgets draw themselves, how a label the template draws reaches the control (labelledBy), and the order itsFieldTemplatedraws the description and help in (fieldTemplateOrder), so a screen reader announces them in the order they appear.mergeThemePresentation()layers it over core's, and theForm'spresentationprop over the theme's, so a custom widget or field can declare the parts it draws. @rjsf/utilsadds helpers that read the plan, among themresolveFieldPresentation(),widgetAriaProps(),getControlAttributes()andgetGroupAttributes(), which give a control or a group of radios or checkboxes itsaria-labelledby,aria-describedbyandaria-invalid, andtemplateDrawsLabel(),templateLabelFor(),templateMarksRequired()andhasWidgetErrors(), which tell a template what to draw.@rjsf/snapshot-testsadds contract tests a theme can run, such aspresentationContractTests(),checkboxLabelTests(),controlNameTests()andrequiredCueTests(), which check that each control is named and described once and each part is drawn exactly once.
Working with form data
- A form passed
formDatareads it only when you pass a value other than the one you passed before, so an unrelated prop change no longer replaces the edits you didn't store. A form passedinitialFormDataowns its data, as in v6. See formData and initialFormData. - A React Server Component, such as a Next.js App Router page, can import and render
Formdirectly, without a'use client'module of your own. See Server components. - A ref typed
FormRef<T>reads the current value withgetFormData(), so you no longer have to copy everyonChangeinto state to know what the form holds. See The imperative handle. getStatus()reports whether the data differs from its baseline, which fields the user touched and how many submits reached the form. You can warn before closing a page with unsaved edits or disable submit until something changed. See Read the form status and Unsaved changes.onSubmitcan return a promise. Until it settles, the form ignores another submit and marks its submit button pending, and it works withuseActionState. See A pending submission.- The
transformChange(next, previous)prop decides what each edit leaves the form with, so you can refuse or rewrite an edit in one place. See transformChange.
Validation and required fields
liveErrors="field"shows a live-validated field's errors only once the user has changed it or left it, or after a submit, so editing one field no longer shows errors on fields the user hasn't reached yet. See liveErrors.ui:requiredmakes a field required from the uiSchema, and the form enforces it on submit and in live validation.ui:initialValuepre-fills a field without adding adefaultto the schema. See required and initialValue.
Schemas the form can now render
- A field whose
typelists several types, such as['string', 'number', 'null'], can show a selector of those types beside the field for the chosen one whenuseFallbackUiForUnsupportedTypeis on. See Multiple types. - When
propertyNameslists the allowed key names, each additional property's key is a dropdown of the names still free. See Constraining key names withpropertyNames. additionalPropertiesWhenAbsent="allow"reads an object that names noadditionalPropertiesas taking extra keys, as JSON Schema does, and gives it an add button. See Objects naming noadditionalProperties.ui:options.optgroupsgroups a select's options under headings, in@rjsf/coreand every theme. See optgroups.
TypeScript
StrictUiSchemais an opt-inUiSchematype that rejects aui:widget,ui:fieldorui:optionsvalue that doesn't fit the field's type. You can adopt it one form at a time. See Type-safe UiSchema.