# How do target configurations and design attributes work in the component's .js-meta.xml file?

**Topic:** LWC · **Difficulty:** Medium · **Tags:** LWC, Metadata Configuration, App Builder

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-target-configurations-and-design-attributes-work-in-the-component-s-js-meta-xml-file

## Answer

**Basics:** Every LWC bundle has a metadata file. `isExposed` makes it visible to builders; `masterLabel` and `description` name it in App Builder; `targets` list placements such as `lightning__RecordPage`, `lightning__AppPage`, `lightning__HomePage`, `lightning__Tab`, `lightning__RecordAction`, `lightning__FlowScreen`, `lightning__UtilityBar` and `lightningCommunity__Page`. Without exposure and targets, the component is only usable inside other components.

**How it works:** Under `<targetConfigs>`, each `<targetConfig targets="...">` can include `<property>` elements (design attributes) that map to `@api` fields. Attributes: `name` (must match the `@api` property), `type` (String, Integer, Boolean, Color in supported contexts), `label`, `description`, `default`, `required`, `min`/`max`, `datasource` (comma list for a picklist, or `apex://ClassName` for dynamic values). Restrict record pages to specific objects with `<objects><object>Account</object></objects>`, and flow screens use `role="inputOnly"` or `outputOnly`. For quick actions, add `lightning__RecordAction` with `<actionType>ScreenAction</actionType>` or `Action`.

**Advanced / deep dive:** `recordId` and `objectApiName` are auto-supplied on record pages and need no property definition, only `@api recordId;`. `supportedFormFactors` restricts to Large/Small. Properties can differ per target by using separate `targetConfig` blocks. Dynamic picklists use an Apex class extending `VisualEditor.DynamicPickList` and are referenced via `datasource="apex://MyPicklist"`. Changes to the XML require redeploy and sometimes a builder refresh. In managed packages, exposed components become part of the package API. If an `@api` property has a setter-only or complex type (object, array) it cannot be exposed in the builder; take String/JSON and parse.

**Code / config example:**
```xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>61.0</apiVersion>
    <isExposed>true</isExposed>
    <masterLabel>Case Summary</masterLabel>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordPage">
            <objects><object>Case</object></objects>
            <property name="title" type="String" label="Card title" default="Summary"/>
            <property name="maxRows" type="Integer" label="Max rows" min="1" max="50" default="5"/>
            <property name="view" type="String" datasource="Compact,Detailed" default="Compact"/>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>
```

**Hidden gotchas & must-remember points:**
- Property `name` must exactly match an `@api` property or deployment errors.
- `isExposed` false hides it from builders even with targets.
- Design attributes are static per placement; they are not data bindings.
- Object restrictions only apply to record page targets.
- Unsupported property types (objects, arrays) cannot be configured in the builder.
- A new target such as `lightning__RecordAction` requires its own `actionType`.

**Best practice:** Expose only what admins need, give every property a clear label and default, and keep objects/targets as narrow as practical.

---
Source: ForceChallenges · last updated 2026-11-02
