After discussing it briefly with @almet and @magopian, I think we could offer an API to support themes.
A theme would be a way to define what the HTML semantics would be for rendering fields, a little what custom fields offer today, but it a more complete and generic way.
There would be a default theme, which would basically provide the same semantics as the ones we expose today.
Defining the theme to use would be done by providing an ui:theme
key at the root of the uiSchema
object:
const uiSchema = {
"ui:theme": "bootstrap"
};
A theme should be exposed in a requirable module, which name would be in the form react-jsonschema-form-theme-${themeName}
; eg.:
$ npm install react-jsonschema-form-theme-bootstrap --save
This would allow the community to create and share different themes.
Writing a theme would basically be matter of defining a set of custom fields and widget components for base jsonschema types:
const BootstrapSchemaField = (props) => {
const {schema, name, uiSchema, formData, widgets, required, onChange} = props;
return (
...
);
};
export default {
SchemaField: BootstrapSchemaField
};
Alternatively, we may rather want to expose hooks for defining SchemaField
's Wrapper
and ErrorList
inner component? Most theming would be about html semantics, class names and so on anyway.
Feedback welcome.