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

14

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 at 15:29
  • @ankittaneja It's in the documentation.
    – sfdcfox
    Jun 23 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.