
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
@codegouvfr/rjsf-dsfr
Advanced tools
This is a wrapper around the
react-jsonschema-form
with the components from
react-dsfr
.
[!IMPORTANT] For now, this is simply extracted code from
catala-dsfr
. Therefore, the API is not yet defined and and is likely to be not flexible enough for your use case.If you want to use this library, please open an issue to discuss your needs!
yarn add @codegouvfr/rjsf-dsfr
For now, the API matches the one from react-jsonschema-form
and you can
overrides some widgets (resp. templates) by specifying them in the props.
import { RJSFSchema } from '@rjsf/utils'
import FormDSFR from '@codegouvfr/rjsf-dsfr'
import { customizeValidator } from '@rjsf/validator-ajv8'
import frenchLocalizer from 'ajv-i18n/localize/fr'
const validator = customizeValidator({}, frenchLocalizer)
const schema: RJSFSchema = {
type: 'object',
properties: {
nom: { title: 'Nom', type: 'string', minLength: 2 },
prenom: { title: 'Prénom', type: 'string' },
ddn: { title: 'Date de naissance', type: 'string', format: 'date' },
},
required: ['nom'],
}
export default function Form() {
return <FormDSFR schema={schema} validator={validator} />
}
The titles must not be defined inside "kind"
properties of the object
definition but just before the "$ref"
of the calling parent:
"categorieEquivalenceLoyerD84216": {
"title": "Catégorie de personnes résidant en logement-foyer",
"$ref": "#/definitions/categorie_equivalence_loyer_allocation_logement_foyer"
}
As described in the react-jsonschema-form
documentation,
you can customize the form by providing a uiSchema
.
In addition to the standard options, you can use the following specific options
for rjsf-dsfr
.
[!TIP] You can have a look to a real world example here
The following options can be set for any field in the uiSchema
:
ui:heading
: set the heading level for the field's title (available values: h2
, h3
, h4
, h5
, h6
)ui:hideTitle
: hide the field's title.The following options can be set for fields of type array
:
ui:addIcon
: set the DSFR icon id for the Add buttonui:removeIcon
: set the DSFR icon id for the Remove buttonui:tabLabel
: set the label for the tab in the array field (it needs to be
defined at the root of the array
field)[!NOTE] By default, array fields are displayed in a
Tabs
component. Each tab is labeled with theui:tabLabel
value and the last tab contains the Add button.
[!IMPORTANT] The
ui:hideTitle
option it's needed for items of typeobject
inside a field of typearray
to hide the unique title of the array's items.Example:
"personnesACharge": { "ui:tabLabel": "Personne", "items": { "ui:hideTitle": true, ...
Launch the playground to play with the DSFR theme :
cd demo
yarn
yarn start
FAQs
react-jsonschema-form with the DSFR
The npm package @codegouvfr/rjsf-dsfr receives a total of 0 weekly downloads. As such, @codegouvfr/rjsf-dsfr popularity was classified as not popular.
We found that @codegouvfr/rjsf-dsfr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.