I have added two new Custom tab in account page

  1. Student
  2. Parents
    ( Both are stored in Contact object mapped to Account)

On click of student tab need to display the students details in data-table, As same as On click of Parents tab need to display the Parents details in data-table.

I trying to achieve this in Single LWC page. if we get the Custom tab label name will get the record type for the contact and display the record.

My Question is onclick of Custom tab in lightning app builder,will be able to get the tab label name in LWC.

  • The custom tab you mean the custom tab in lightning app builder? Jun 16, 2020 at 6:09
  • Yes Rahul, custom tab in lightning app builder Jun 16, 2020 at 6:11
  • 2
    Don't use the label - it can be localized.
    – Phil W
    Jun 16, 2020 at 7:41

1 Answer 1


Well afaik, you can't get the selected tab, but there is another way. You can use a design attribute here. Let's say Type, and you can use the same component in both tabs with different values to the Type design attribute.

Configure a Component for Lightning App Builder

You need to define a public attribute for that, like.

@api Type

Based on the value of Type you can do your logic.

if(this.Type === 'Student'){
     // do the logic to fetch the students data
} else if (Type === 'Parents'){
     // do the logic to fetch the parents data.

Also, you need to make this attribute available to the lightning app builder by defining the below code in lwc's meta XML file.

    <targetConfig targets="lightning__RecordPage">
        <property name="Type" type="String" datasource="Student,Parents" />

Now the Type value you can set directly from app builder. Which looks something like this.

enter image description here

  • Not getting you Rahul, can you please help me to understand on this. Jun 16, 2020 at 6:37
  • @SFDC_Beginner I have updated the answer. Jun 16, 2020 at 7:15
  • 1
    Thanks Rahul, For Making me to understand on this :) Jun 16, 2020 at 15:33
  • This worked for me. Thanks a lot!
    – user123397
    Oct 12, 2022 at 8:55

You must log in to answer this question.

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