The shadcn theme renders core's templates with its classes
Detect
- CSS, tests or snapshots that reach a field, object, array, description, error or additional property rendered by
@rjsf/shadcnthrough its olddivstructure. - Selectors for a field's errors as a
divofspans, or for ahiddenclass on a hidden field. - Snapshot tests of a shadcn form, which fail on the new markup.
Change
@rjsf/shadcn declares a classMap and renders @rjsf/core's FieldTemplate, DescriptionField (core's DescriptionFieldTemplate), FieldErrorTemplate, FieldHelpTemplate, MultiSchemaFieldTemplate, ArrayFieldTemplate, ArrayFieldItemTemplate and ObjectFieldTemplate with Tailwind classes, in place of its own copies. It styles core's AltDateWidget, which it falls back to, through the same class map: its parts sit in one wrapping row, with Now and Clear as outline buttons. Its widgets and the templates built on its components/ui primitives (BaseInputTemplate, the buttons, ErrorList, CyclicSchemaExpandTemplate, OptionalDataControlsTemplate, TitleField) stay, and so do WrapIfAdditionalTemplate and GridTemplate.
Point CSS and tests that used the old div structure at core's markers, such as rjsf-array-item-list, rjsf-array-item-toolbox and rjsf-error-detail. To restyle one of the elements, pass a classMap to the Form, as the custom themes page describes. Then update your snapshots.
Verify
- An object or an array renders in a
<fieldset>, and an array's items in core'srjsf-array-item-list. Each item is a grid with its buttons in anrjsf-array-item-toolboxbeside the field. The buttons are top-aligned and sit level with the field's input, past its label and description however far they wrap or however aclassMaprestylesfieldLabelorfieldDescription, as core'srjsf.csslays them out. A customFieldTemplatekeeps that by keeping core's classes. TitleFielddraws an object's or array's title in a<legend>, which names its<fieldset>, followed by the separator. It used to be adivholding both.- A field's description is drawn above its widget, as core draws it. It used to be below.
CheckboxWidgetrendered without a plan draws no description of its own whereui:widgetis thecheckboxalias, since core'sFieldTemplatedraws it there, as@rjsf/core's checkbox does. - A field's errors are core's
<ul class="rjsf-error-detail">of<li>items. - A field's label, description and help turn destructive through a
data-invalid:text-destructivevariant beside their class, on thedata-invalidattribute core sets while the field shows its own errors. - A hidden field uses the
hiddenattribute instead of ahiddenclass. AddButtonrenders its button with no row around it. ThearrayFieldsetandobjectFieldsetclass-map entries align it to the end of the array or object, so one placed in a custom template carries no margin of its own.WrapIfAdditionalTemplatelays an extra key's label and input, the value and the remove button out on shared grid rows instead of pixel offsets. The key input and the remove button sit level with the value's input however far its label or description wraps and whatever errors or help follow it, as under@rjsf/core(see Lining up a customFieldTemplate).
Also read: