Define a Property-Level Editor Override
You can define a specific editor for an individual property within your custom Lightning type in the editor.json file. This editor applies only to the specified property, while default editors continue to handle the remaining properties.
For example, you have a custom Lightning type named contactType with two properties: firstName and lastName. You want to use a custom input component to handle the lastName property (perhaps to add specific validation or styling), while the default text editor handles the firstName.
Here’s an example of what the editor.json file organization looks like for the custom Lightning type contactType.
Example: Configuration Using Property Names
This example shows you how to configure a component to handle a specific property. The component receives only the value for that property via an @api value property.
-
Define the schema.json file.
This schema defines the data structure. It defines afirstNameandlastNameproperty, but you override only thelastName. -
Create the LWC Bundle.
Create a custom Lightning Web Component (such asc/customLastNameInput) to handle the specific property.
ThecustomLastNameInput.htmltemplate binds the standard input component to your custom logic.The
customLastNameInput.jsfile handles the data flow. The component exposes public properties—such asvalue,label, andrequired—to receive data. To capture the user's input, the component dispatches avaluechangeevent whenever the value updates.The
customLastNameInput.js-meta.xmlfile exposes the component to the editor. -
Configure the editor.json file.
Use the property namelastNameas the key in thecomponentOverridessection.
Here’s how to referencecustomLastNameInputto override the editor in theeditor.jsonfile.
Example: Layout Configuration
If you're reusing an existing component and decide to use layouts, you can combine the layout and componentOverrides sections in the editor.json file. With this approach, you control the visual arrangement of properties while simultaneously assigning a specific custom component to handle the behavior of an individual property.
In this scenario, you arrange the firstName and lastName properties horizontally by using a layout, while specifically overriding the lastName property to use a reused custom component (c/customLastNameInput).
-
Define the schema.json file.
This schema defines the data structure. It defines afirstNameandlastNameproperty, but you override only thelastName. -
Create the LWC Bundle.
Create a custom Lightning Web Component (such asc/customLastNameInput) to handle the specific property.
ThecustomLastNameInput.htmltemplate binds the standard input component to your custom logic.The
customLastNameInput.jsfile handles the data flow. The component exposes public properties—such asvalue,label, andrequired—to receive data. To capture the user's input, the component dispatches avaluechangeevent whenever the value updates.The
customLastNameInput.js-meta.xmlfile exposes the component to the editor. -
Configure the editor.json file.
Use the property namelastNameas the key in thecomponentOverridessection.
Here’s how to referencecustomLastNameInputto override the editor in theeditor.jsonfile.When you use
lightning/propertyLayoutto place a property, the editor checks for a correspondingcomponentOverridesdefinition. If an override exists (such as in thelastNameexample), the custom component renders. Otherwise, the default input renders.