10

I am using lightning:input type="toggle" base component and I need to set the text underneath the toggle button.

By default checked displays Active:

enter image description here

And unchecked displays Inactive:

enter image description here

Here is my code:

<lightning:input type="toggle"
                 label="My Label: "
                 name="toggle"
                 checked="{!v.record.myCheckbox__c}"/>

I want to change these messages and cannot find a way to do it - is there a way?

1 Answer 1

15

Use messageToggleActive and messageToggleInactive:

<lightning:input name="x"
                 label="x"
                 type="toggle"
                 messageToggleActive="Done"
                 messageToggleInactive="Not Done" />

Not Done


Done

3
  • 1
    Works like a charm! so many Attributes for this component so I have missed these. Thanks Feb 27, 2018 at 16:50
  • @sfdcfox: Where did you find this info coz I was looking for the same. Thanks for the answer. Update: As soon as I typed "mes.." viscode showed me the options. Should have thought of that. Jun 23, 2022 at 15:29
  • @ankittaneja It's in the documentation.
    – sfdcfox
    Jun 23, 2022 at 15:56

You must log in to answer this question.

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