FieldTemplate decides which widget renders the label by matching the ui:widget string, so a registry key or component renders it twice

Author: heath-freenomeCreated Sep 29, 2026Updated Sep 30, 2026
Labelsneeds triage

Prerequisites

What theme are you using?

core, antd, chakra-ui, fluentui-rc, mui, react-bootstrap, shadcn

Version

7.x (v7 branch)

Current Behavior

A checkbox reads as its own label, so a FieldTemplate has to know that the widget about to render will draw the label itself and skip its own. Every theme answers that question by matching the spelling of ui:widget:

typescript
const isCheckbox = uiOptions.widget === 'checkbox';

ui:widget accepts three things, and only one of them is that string:

  1. an alias — 'checkbox' — which getWidget() resolves through the schema's type
  2. a registry key — 'CheckboxWidget', or a theme's own key such as daisyUI's 'toggle'
  3. a component, passed inline

So a consumer who writes ui:widget: 'CheckboxWidget', or wraps the theme's widget (widgets={{ CheckboxWidget: (p) => <CheckboxWidget {...p} /> }}), or passes a component that renders its own label, gets two labels: the template's and the widget's. The description is duplicated the same way wherever it is gated on the same flag. There is no way to suppress only the template's — ui:options.label: false sets hideLabel too, so the widget drops its label as well and the field ends up with none.

Expected Behavior

The question is answered from the resolved widget rather than from how ui:widget is spelled, so all three spellings agree and a wrapper or replacement registered under the checkbox key renders exactly one label.

@rjsf/daisyui now does this locally in #5356:

typescript
function widgetRendersOwnLabel(schema, widget, registeredWidgets) {
  // Only an alias is resolved through the schema's type, and an alias is the one spelling getWidget()
  // reports it cannot resolve by *throwing* — with a message built from JSON.stringify(schema)
  const isAlias = typeof widget === 'string' && !(widget in registeredWidgets);
  if (!widget || (isAlias && getSchemaType(schema) !== 'boolean')) {
    return false;
  }
  let resolved;
  try {
    resolved = getWidget(schema, widget, registeredWidgets);
  } catch {
    return false;
  }
  return resolved === registeredWidgets.CheckboxWidget || resolved === registeredWidgets.toggle;
}

CLAUDE.md asks for exactly this to be lifted: "If substantial logic is duplicated across themes, consider refactoring the logic to @rjsf/utils or @rjsf/core."

Things a shared helper has to settle, which is why it is a PR of its own rather than a rider on a theme fix:

  • Which keys count. CheckboxWidget is common to every theme; toggle is daisyUI's own. The helper probably takes the keys as an argument rather than hard-coding them.
  • Label and description are not the same question. Some themes gate both on isCheckbox, some only one, and they disagree about which of the template and the widget should own the description.
  • An unrecognized widget is a judgement call. A widget registered under any other key cannot be recognized, and it is better to render the template's label as well as its own than to guess the other way and leave a label-less widget with no accessible name at all.
  • Do not pay for the miss path. getWidget() builds its error message with JSON.stringify(schema), so a ui:widget that does not resolve for the field — an object with a ui:widget consumed by a custom ui:field, say — would stringify the whole subschema on every render just to be told no. Hence the isAlias/getSchemaType short-circuit above.

Each theme's FieldTemplate then calls the shared helper, which moves snapshots in every package that has a checkbox rendered through a non-alias spelling.

Steps To Reproduce

typescript
<Form
  schema={{ type: 'object', properties: { agree: { type: 'boolean', title: 'Agree' } } }}
  uiSchema={{ agree: { 'ui:widget': 'CheckboxWidget' } }}
  validator={validator}
/>

"Agree" renders twice: once from FieldTemplate above the control, once from CheckboxWidget beside it. Same with a wrapper registered as CheckboxWidget, or with a component passed inline.

Anything else?

Raised twice in review on #5356 (1, 2) and deliberately kept out of it both times, so the daisyUI fixes were not buried under cross-theme snapshot movement.

Source: rjsf-team/react-jsonschema-form