react-jsonschema-form

rjsf-teamApache-2.0活跃维护

用 JSON Schema 自动生成 React 表单,省去手写表单和校验逻辑,适合配置化、动态表单场景。

A React component for building Web forms from JSON Schema.

v6.11.1发布于 2026-11-05 08:16 UTC15,938star +3 / 7 天2,350fork同步于 2026-11-10 11:25 UTC

怎么上手

由 README 提炼,执行前请确认
npm install @rjsf/core @rjsf/utils @rjsf/validator-ajv8
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 JSON Schema 声明式生成 React 表单的组件库,省去手写表单代码

用 JSON Schema 自动生成 React 表单,省去手写表单和校验逻辑,适合配置化、动态表单场景。

核心能力

  • 根据 JSON Schema 声明式构建并自定义 Web 表单
  • 提供 Ant Design、MUI、Chakra UI 等十余种主题包
  • 拆分出 @rjsf/utils 与多种 validator 校验库
  • 提供在线 Playground 可直接试玩表单效果

容易踩的坑

主题与校验器是独立包,需按需额外安装对应主题包和 validator 包;README 未给出具体安装命令,上述命令需按官方文档核对

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v6.11.1
  1. v6.11.16.11.1最新正式版2026-11-05 · 2026-11-05 08:16 UTC

    @rjsf/core

    • Updated markdown-to-jsx from ^9.8.2 to ^9.10.3 (#5420)
    • Fixed Form failing validation with must be boolean (or the matching type error) when the root formData is a falsy value such as false, 0 or ''. Only undefined is now treated as missing before validating, fixing #5404
    • Fix Form crashing with Maximum update depth exceeded when a widget or setFieldValue() calls onChange more than about 50 times in one event (#5631, #5532)
    • Fix Form ignoring later changes after a change whose customValidate or transformErrors throws. The form keeps its state and the error is rethrown from a timeout (#5631)
    • Potentially breaking change: Change setFieldValue() so a throw from customValidate or transformErrors is rethrown from a timeout, so a try/catch around setFieldValue() no longer catches it (#5631)
    • Potentially breaking change: Change Form to no longer call its deprecated omitExtraData() method, so a subclass overriding it no longer affects liveOmit, a submit or validateForm(). A submit no longer calls validateFormWithFormData() either (#5631)
    • Potentially breaking change: Change customValidate, transformErrors and the validator to run while Form renders a change, so they must be pure: they can run more than once per change, and must not set another component's state (#5631)
    • Potentially breaking change: Remove the undocumented Form members pendingChanges and processPendingChange() (#5631)
    • Change noValidate to hide custom errors a widget raised, including ones raised before it was turned on; they show again once it is turned off (#5631)
    • Fix ErrorList and the onChange event still listing a widget's custom error after an edit cleared it, with live validation off (#5631)
    • Change live validation on change to run once per burst of changes in one event, for the last one; the events of the changes before it report the errors from before the burst (#5631)
    • Fix Form reverting changes made in the same event as a submit, or as a blur with liveValidate or liveOmit set to 'onBlur'. A throw from a blur's live validation is now rethrown from a timeout (#5631, #5660)
    • Potentially breaking change: Change a submit to validate and submit the data and schema of the changes made in the same event, rather than those from before them, so onSubmit gets the data the form shows. Its customValidate and transformErrors now run while Form renders, focusOnFirstError is called after the errors render, and a throw is rethrown from a timeout. With createRoot, a change made outside a React event, such as after an await, or in a transition is still not included (#5631)
    • Fix a blur with liveOmit set to 'onBlur' omitting extra data against the schema from before a schema change the parent made in the same event as a field change (#5631)
    • Fix the errors of an old schema coming back after a schema chang
  2. v6.11.06.11.02026-09-28 · 2026-09-28 23:53 UTC
    查看更新说明

    New feature

    @rjsf/core

    • Fixed a schema prop change being silently dropped when it adds a property with a default, either as the parent's reply to onChange or at any point after a change to an uncontrolled form. The guard that keeps a oneOf/anyOf option switch from reverting now only applies when the form re-derives its own formData (an uncontrolled form, or a parent holding what onChange emitted, including when it reshaped the emitted value by spreading it, storing undefined as null or round-tripping it through JSON) with the same schema and experimental_defaultFormStateBehavior, and it keeps only that formData rather than dropping the rest of the prop update, fixing #5294
    • Fixed switching between oneOf/anyOf options keeping a value the previous option's default put there, so a property whose value still matches that default, or a whole option that does, now picks up the new option's default the way a scalar property already did, and switching back to an option restores its own defaults. A property the new option cannot hold as it stands now picks the new default up as well instead of arriving empty — one whose type differs between the options, or a readOnly one edited away from its default. Values are compared whole, so a nested object the user has partly edited keeps the rest of the old option's defaults, and a value equal to the old default is replaced no matter who supplied it, including one passed in formData, since the two cannot be told apart, fixing #4476

    @rjsf/utils

    • Updated Experimental_DefaultFormStateBehavior to add a new requiredBooleanDefault option, and updated getDefaultFormState() to honor it: skip turns off the false populated for a required boolean with no default (introduced in 6.9.0 by #5170), so a form that models an unanswered boolean as its own state can keep it undefined and let required report it. The default, populateFalse, keeps the 6.9.0+ behavior

    @rjsf/validator-ata

    • Updated ata-validator from ^1.7.1 to ^1.23.0, picking up the corrected error shape for unevaluatedProperties (the error now carries params.unevaluatedProperty), the removal of a quadratic in additionalProperties: false schemas with many properties, a fix for a hang on truncated JSON input, and enforced strict-mode schema checks (#5293)

    Dev / docs / playground

    • Documented the requiredBooleanDefault option in form-props.md and internals.md, and added a selector for it to the playground
  3. v6.10.16.10.12026-09-16 · 2026-09-16 15:29 UTC
    查看更新说明

    @rjsf/core

    • Fixed a dependencies/if branch switch nested inside an object property never sanitizing a sibling field's now-invalid value. The check gating sanitization only compared the root retrieved schema, which never reflects a conditional resolved deeper in the tree, so it always skipped sanitizing in that case, fixing (#5250)
    • Fixed NumberField losing or misinterpreting decimal input in comma-decimal locales, and passing a locale-formatted string instead of a number to custom and format-registered widgets, fixing #5199 and #5241
    • Fixed NumberField still comma-formatting the displayed value for a text widget with an explicit ui:options.inputType override in a comma-decimal locale; getInputProps() gives that override priority over the locale-based text fallback, so it rendered a native, locale-unaware <input type="number"> that rejected the comma-formatted string

    @rjsf/mantine

    • Fixed BaseInputTemplate passing an undefined value straight through to NumberInput/TextInput, which let the DOM input fall out of sync with React's controlled value and retain a stray digit after clearing a multi-digit number field (#5269)
    • Backported the fluid Container layout fix from the v7 Mantine 9 upgrade (#5260): GridTemplate's and ObjectFieldTemplate's root Container now use Mantine's fluid prop so forms fill their available width instead of centering at Mantine's default 960px max-width

    @rjsf/shadcn

    • Fixed the documented import '@rjsf/shadcn/dist/[theme].css' failing to resolve. The prebuilt stylesheets were in the published tarball but no exports entry matched them, so Node and every bundler that honours the exports map rejected the path

    @rjsf/utils

    • Fixed sanitizeDataForNewSchema() to resolve dependencies, if/then/else and allOf (not just $ref) on each property's old/new schema before comparing them, so a conditional nested inside an object property is taken into account when sanitizing its data, fixing (#5250)
    • Added schemaHasNestedConditional(), which Form uses to detect a dependencies/if nested below a schema's top level (behind a $ref, patternProperties, tuple items, additionalProperties or allOf/anyOf/oneOf) so sanitization isn't skipped just because the root retrieved schema looks unchanged (#5250)
    • Fixed getInputProps() defaulting type: number schemas to a native number input in locales whose decimal separator isn't ., where the browser rejects the localized value; it now defaults to a text input in those locales unless an explicit inputType is set
    • Added resolveDefaultWidget(), extracting the widget-name/enumOptions fallback logic shared by @rjsf/core's StringField and NumberField so the two can no longer drift out of sync
    • Upgraded @x0k/json-schema-merge to ^1.0.6, which now preserves Symbol-keyed properties (e.g. Symbol(__rjsf_ref)) when merging allOf schemas and no longer collapses distinct allOf.contains branches into one over-constrained schema; removed the corresponding Symbol-preservation and contains-extraction workarounds from retrieveSchemaInternal(), fixing (#5146)
    • Fixed defaults from a dependency subschema being omitted when getDefaultFormState() is called without form data or with an empty object, fixing #5198
    • Fixed computeDefaults() to merge a non-object schema's
  4. v6.10.06.10.02026-09-09 · 2026-09-09 16:27 UTC
    查看更新说明

    New Feature added

    autocapitalize support was added to the uiSchema

    Also, since 6.9.0 failed to release properly, this also contains all of its content

    @rjsf/chakra-ui

    • Removed an environment prop the test wrapper passed to EnvironmentProvider, which has no such prop and silently ignored it

    @rjsf/core

    • Fixed defaults not being restored when returning to an anyOf or oneOf option with disjoint properties (#3736)
    • Added ui:autocapitalize support for inputs rendered by BaseInputTemplate, allowing mobile keyboards to apply the requested capitalization behavior (#2187)

    @rjsf/mantine

    • Added ui:autocapitalize support for text inputs (#2187)

    @rjsf/mui

    • Added ui:autocapitalize support for text inputs (#2187)

    @rjsf/utils

    • Fixed sanitizeDataForNewSchema() clearing existing arrays or preserving stale undefined values instead of retaining data or applying defaults for properties newly defined by the incoming schema (#3736)
    • Added autocapitalize UI option handling to getInputProps() and its public input prop types (#2187)

    @rjsf/validator-ajv8

    • Changed the standaloneCode import to name the file, ajv/dist/standalone/index.js, instead of the directory subpath ajv/dist/standalone. A tsc-alias replacer used to patch this into the emitted output; the source now says what it means. No public API changed

    Dev / docs / playground

    • Relative TypeScript imports now name their real .ts/.tsx source file (and an explicit index.ts for directory imports), and TypeScript's rewriteRelativeImportExtensions emits the .js specifiers directly. This removes tsc-alias and its post-emit string rewriting entirely, along with the tsc-alias-replacer/ directory, both tsconfig.replacer.json files, the compileReplacer scripts and move-file-cli. Naming the source file rather than the output is deliberate: Node's native type stripping requires exact .ts extensions and does no extension or directory-index searching, so this avoids a second repository-wide import migration later
    • Fixed packages/daisyui/test/tsconfig.json, which was configured to emit into ../dist — the esbuild/rollup bundle output directory — instead of type-checking without emit like every other test project
    • Collapsed each package's tsconfig.json + tsconfig.build.json + src/tsconfig.json chain into one source config plus one test config extending a new shared root tsconfig.test.json. Building a package no longer pulls its dependencies' test projects into the graph
    • Fixed the root tsconfig.json, which referenced snapshot-tests twice and omitted mantine, primereact, validator-ata and validator-cfworker. It now lists every source and test project once, and a new root typecheck script runs in CI, so tests are typechecked for the first time. That surfaced stale tests in @rjsf/chakra-ui and @rjsf/validator-ata and two drifted playground samples, fixed here. @rjsf/chakra-ui's type-check script previously ran against a solution config with files: [] and checked nothing
    • Every package now emits lib/ with the same settings: esnext target plus .js.map and .d.ts.map. Previously only @rjsf/core did; the rest emitted ES2018 with JS source maps only, depending on which root config their src/tsconfig.json extended
    • tsconfig.tsbuildinfo is no longer written into lib/ and publis
  5. v6.9.06.9.02026-08-30 · 2026-08-30 21:07 UTC
    查看更新说明

    Potentially breaking change: lodash and lodash-es are no longer dependencies of any @rjsf/* package. No RJSF public API changed, but an application that imports lodash itself without declaring it — relying on it being hoisted into node_modules because RJSF depended on it — must now add lodash to its own package.json.

    @rjsf/antd

    • Updated CheckboxWidget to append a * onto the end of the label when the field is required AND the schema value is hardcoded to true, fixing #4136
    • Declared "sideEffects": false in package.json, allowing bundlers to tree-shake unused exports
    • Fixed BaseInputTemplate to clear number/integer fields back to undefined instead of null when the InputNumber widget is emptied, fixing #5213
    • Fixed BaseInputTemplate's ui:allowClearTextInputs clear button to store ui:emptyValue (undefined by default) instead of always storing "", so clicking it now behaves exactly like clearing the input by typing. Potentially breaking change: an app that never sets ui:emptyValue and clicks the clear button on a field (rather than backspacing it) previously got "" back; it now gets undefined, matching every other way of emptying the field.

    @rjsf/chakra-ui

    • Updated CheckboxWidget to append a * onto the end of the label when the field is required AND the schema value is hardcoded to true, fixing #4136
    • Declared "sideEffects": false in package.json, allowing bundlers to tree-shake unused exports
    • Fixed BaseInputTemplate's ui:allowClearTextInputs clear button to store ui:emptyValue (undefined by default) instead of always storing "", so clicking it now behaves exactly like clearing the input by typing. Potentially breaking change: an app that never sets ui:emptyValue and clicks the clear button on a field (rather than backspacing it) previously got "" back; it now gets undefined, matching every other way of emptying the field.

    @rjsf/core

    • Declared "sideEffects": false in package.json, allowing bundlers to tree-shake unused modules; a consumer importing only Form no longer bundles the AJV validator chain pulled in by getTestRegistry, shrinking a minimal bundle by ~34kB gzipped
    • Fixed TimeWidget to respect schema multipleOf time precision, preserving second-precision values while keeping minute-precision native inputs synchronized with their displayed value (#5174)
    • Replaced all path-based lodash usage (get, set, unset, toPath, pick) with the new @rjsf/utils path utilities
    • Replaced the remaining non-path lodash usage (isEmpty, isObject, isPlainObject, each, flatten, includes, intersection, last, uniqueId, noop) with native equivalents, and dropped the lodash/lodash-es dependencies entirely
    • Fixed the clearing of errors on change so that only the field that actually changed loses its error, along with the errors the containers holding it own, rather than every field under the top-level key holding it, fixing #5197 (#5205)
    • Updated CheckboxWidget to append a * onto the end of the label when the field is required AND the schema value is hardcoded to true, fixing #4136
    • Renamed the test file Form.test.tsx to Form.behaviors.test.tsx so all the Form test files follow the Form.<topic>.test.tsx naming pattern introduced by #5219
    • Fixed ObjectField to coerce a cleared additionalProperties/patternProperties value to the

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Build Status Contributors Apache 2.0 License

    playground animation

    Supported Themes

    API Libraries

    Documentation

    Read our documentation, powered by Docusaurus.

    Live Playground

    A live playground is hosted on GitHub Pages.

    Contributing

    Read our contributors' guide to get started.

    Credits

    Testing powered by BrowserStack