CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-rjsf--material-ui

Material UI theme integration for react-jsonschema-form providing dual v4/v5 compatibility with Material Design components, widgets, fields, and themes for JSON schema-based forms.

Pending
Overview
Eval results
Files

themes.mddocs/

Themes

Theme objects that configure the complete form appearance and behavior for different Material UI versions. Themes integrate with @rjsf/core's theming system to provide Material UI-specific implementations.

Capabilities

Theme (Material UI v4)

The default theme for Material UI v4 with Mui4FormWrapper and complete component integration.

/**
 * Material UI v4 theme configuration with Mui4FormWrapper and ThemeCommon
 * Integrates with @material-ui/core components and icons
 */
declare const Theme: ThemeProps;

Features:

  • Mui4FormWrapper for @material-ui/core v4 component context
  • Complete widget and field collection
  • Error handling with Material UI v4 components
  • Theme-consistent styling and behavior

Usage:

import { withTheme } from "@rjsf/core";
import Theme from "@rjsf/material-ui/v4";

const Form = withTheme(Theme);

Theme4

Explicit alias for Material UI v4 theme (same as Theme).

/**
 * Explicit Material UI v4 theme (alias for Theme)
 */
declare const Theme4: ThemeProps;

Theme5

Theme for Material UI v5 with Mui5FormWrapper and @mui/material integration.

/**
 * Material UI v5 theme configuration with Mui5FormWrapper and ThemeCommon
 * Integrates with @mui/material components and icons
 */
declare const Theme5: ThemeProps;

Features:

  • Mui5FormWrapper for @mui/material v5 component context
  • Complete widget and field collection
  • Error handling with Material UI v5 components
  • Modern Material Design 3 styling

Usage:

import { withTheme } from "@rjsf/core";
import Theme from "@rjsf/material-ui/v5";

const Form = withTheme(Theme);

Theme Structure

All themes implement the ThemeProps interface from @rjsf/core:

interface ThemeProps {
  /** Internal form wrapper component for context provision */
  _internalFormWrapper?: React.ComponentType<any>;
  /** Template for array fields */
  ArrayFieldTemplate?: React.ComponentType<ArrayFieldTemplateProps>;
  /** Template for individual fields */
  FieldTemplate?: React.ComponentType<FieldTemplateProps>;
  /** Template for object fields */
  ObjectFieldTemplate?: React.ComponentType<ObjectFieldTemplateProps>;
  /** Collection of custom field components */
  fields?: { [key: string]: React.ComponentType<FieldProps> };
  /** Collection of custom widget components */
  widgets?: { [key: string]: React.ComponentType<WidgetProps> };
  /** Error list component */
  ErrorList?: React.ComponentType<ErrorListProps>;
}

Theme Components

ThemeCommon

Shared theme configuration used by both v4 and v5 themes:

interface ThemeCommonConfig {
  /** Array field template with Material UI styling */
  ArrayFieldTemplate: React.ComponentType<ArrayFieldTemplateProps>;
  /** Combined fields from default registry and custom fields */
  fields: { [key: string]: React.ComponentType<FieldProps> };
  /** Individual field template */
  FieldTemplate: React.ComponentType<FieldTemplateProps>;
  /** Object field template */
  ObjectFieldTemplate: React.ComponentType<ObjectFieldTemplateProps>;
  /** Combined widgets from default registry and custom widgets */
  widgets: { [key: string]: React.ComponentType<WidgetProps> };
  /** Error list component */
  ErrorList: React.ComponentType<ErrorListProps>;
}

Form Wrappers

Mui4FormWrapper

Form wrapper that provides Material UI v4 context to all child components:

/**
 * Form wrapper that provides @material-ui/core v4 components via MuiComponentContext
 * Shows warning if Material UI v4 dependencies are not available
 */
declare const Mui4FormWrapper: React.ForwardRefExoticComponent<
  React.PropsWithChildren<HTMLFormElement> & React.RefAttributes<HTMLBaseElement>
>;

Mui5FormWrapper

Form wrapper that provides Material UI v5 context to all child components:

/**
 * Form wrapper that provides @mui/material v5 components via MuiComponentContext
 * Shows warning if Material UI v5 dependencies are not available
 */
declare const Mui5FormWrapper: React.ForwardRefExoticComponent<
  React.PropsWithChildren<HTMLFormElement> & React.RefAttributes<HTMLBaseElement>
>;

Theme Customization

Basic Theme Extension

import { withTheme } from "@rjsf/core";
import { Theme } from "@rjsf/material-ui/v5";

const customTheme = {
  ...Theme,
  widgets: {
    ...Theme.widgets,
    CustomWidget: MyCustomWidget,
  },
  fields: {
    ...Theme.fields,
    CustomField: MyCustomField,
  },
};

const CustomForm = withTheme(customTheme);

Advanced Theme Customization

import { ThemeProps } from "@rjsf/core";
import { Theme5 } from "@rjsf/material-ui";

const advancedTheme: ThemeProps = {
  ...Theme5,
  FieldTemplate: CustomFieldTemplate,
  ArrayFieldTemplate: CustomArrayTemplate,
  ErrorList: CustomErrorList,
  widgets: {
    ...Theme5.widgets,
    TextWidget: EnhancedTextWidget,
    SelectWidget: EnhancedSelectWidget,
  },
};

const AdvancedForm = withTheme(advancedTheme);

Conditional Theme Selection

import { Theme as Theme4, Theme5 } from "@rjsf/material-ui";

function useThemeForVersion(version: 4 | 5) {
  return version === 5 ? Theme5 : Theme4;
}

function AdaptiveForm({ materialUIVersion = 5 }) {
  const theme = useThemeForVersion(materialUIVersion);
  const Form = withTheme(theme);
  
  return <Form schema={schema} />;
}

Error Handling

All themes include error handling components:

ErrorList Component

Displays form validation errors using Material UI components:

/**
 * Error display component using Paper, List, and ErrorIcon
 * @param props - ErrorListProps containing validation errors
 * @returns JSX.Element
 */
declare const ErrorList: React.ComponentType<ErrorListProps>;

interface ErrorListProps {
  /** List of validation errors */
  errors?: RJSFValidationError[];
  /** Error schema object */
  errorSchema?: ErrorSchema;
  /** Schema being validated */
  schema?: JSONSchema7;
  /** UI schema */
  uiSchema?: UiSchema;
  /** Form context */
  formContext?: any;
}

Integration Examples

With Material UI ThemeProvider

import { createTheme, ThemeProvider } from "@mui/material/styles";
import Form from "@rjsf/material-ui/v5";

const muiTheme = createTheme({
  palette: {
    primary: {
      main: '#1976d2',
    },
    secondary: {
      main: '#dc004e',
    },
  },
});

function ThemedForm() {
  return (
    <ThemeProvider theme={muiTheme}>
      <Form schema={schema} />
    </ThemeProvider>
  );
}

Multiple Forms with Different Themes

import { Theme as Theme4, Theme5 } from "@rjsf/material-ui";
import { withTheme } from "@rjsf/core";

const Form4 = withTheme(Theme4);
const Form5 = withTheme(Theme5);

function MultiVersionForms() {
  return (
    <>
      <h2>Material UI v4 Form</h2>
      <Form4 schema={schema4} />
      
      <h2>Material UI v5 Form</h2>
      <Form5 schema={schema5} />
    </>
  );
}

Custom Theme with Feature Flags

import { Theme5 } from "@rjsf/material-ui";

function createFeatureTheme(features: FeatureFlags): ThemeProps {
  const theme = { ...Theme5 };
  
  if (features.enhancedValidation) {
    theme.ErrorList = EnhancedErrorList;
  }
  
  if (features.advancedWidgets) {
    theme.widgets = {
      ...theme.widgets,
      DateTimeWidget: AdvancedDateTimeWidget,
    };
  }
  
  return theme;
}

const FeatureForm = withTheme(createFeatureTheme({
  enhancedValidation: true,
  advancedWidgets: false,
}));

Version Compatibility

  • Theme/Theme4: Compatible with @material-ui/core v4.12.3+
  • Theme5: Compatible with @mui/material v5.2.2+
  • Context Detection: Themes automatically detect available Material UI version
  • Graceful Degradation: Shows warning messages if required dependencies are missing
  • Peer Dependencies: All Material UI dependencies are optional to support dual installation

Install with Tessl CLI

npx tessl i tessl/npm-rjsf--material-ui

docs

component-context.md

field-templates.md

fields.md

form-components.md

index.md

themes.md

widgets.md

tile.json