What is design Attribute in LWC
We Can use design attributes to make our LWC attributes available to system admin or a developer to edit it in builder tools like Lightning App builder, Community Builder or in a flow designer.
To do so, we will expose the component attribute in any builder tools using design attribute.
As in Aura we have design file where we use <design:attribute> tag but in LWC if we want to define the design attribute we have to use our configuration file i.e. js-meta.xml with <targetConfigs> tag and also we have to define our property as public using @api decorator in our js file.
<targetConfigs><targetConfig targets="lightning__FlowScreen"><property name='' type='' default='' label='' role=''> </property></targetConfig></targetConfigs>
name: It's value must match the property that you have defined in your js (Required)
type: It's define the attribute data type (Required)
default: The default value for the attribute
role: To restrict a property to inputOnly or outputOnly we use this attribute. If you don't define this attribute it will be a default which means that it is available for both inputOnly or outputOnly.
label: It will display as a label for the attribute in the builder tool.
No comments:
Post a Comment