4

I have created a Lightning Component & i want to expose the same in both Desktop & mobile. I used the following in the meta.xml file,the component is either visible in desktop or mobile.. but i need to achieve both - any help regarding this is much appreciated.

  <targets>
    <target>lightning__AppPage</target>
    <target>lightning__RecordPage</target>
    <target>lightning__HomePage</target>
</targets>
<targetConfigs>
    <targetConfig targets="lightning__RecordPage">
        <supportedFormFactors>
            <supportedFormFactor type="small" />
        </supportedFormFactors>
    </targetConfig>

</targetConfigs>

The problem i'm facing is i'm not able to add another targetConfig for "lightning__RecordPage" nor am i able to add supportedFormFactor type="Large" in the existing targetConfig for "lightning__RecordPage".

TIA

1 Answer 1

7

You can do this by adding another <supportedFormFactor type="Small" /> in <supportedFormFactors>:-

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>42.0</apiVersion>
    <isExposed>true</isExposed>
    <masterLabel>Best Component Ever</masterLabel>
    <description>This is a demo component.</description>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordPage">
            <property name="prop1" type="String" />
            <supportedFormFactors>
                <supportedFormFactor type="Large" />
                <supportedFormFactor type="Small" />
            </supportedFormFactors>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

Also, If you don’t define , the component supports the form factors that the page type supports. If your lightning page supports both mobile and desktop form factor, It will apply for the component exist on the page.

App and record pages support the Large and Small form factors. Home pages support only the Large form factor.

enter image description here

2
  • This worked. Initially i had set the form factor to both phone & mobile - so i dint get "Add Another Form Factor". I set to phone & then i was able to get "Add Another Form Factor" button, after which i chose Desktop.
    – Sunil
    Commented Apr 1, 2020 at 17:48
  • 1
    what is property name for under the target config?
    – compski
    Commented Jul 26, 2022 at 11:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .