May 19, 2020

How to make radio button in front of label using Aura components in Salesforce?

Sample Code:

Component:

<aura:component implements="force:appHostable,forceCommunity:availableForAllPageTypes">
   
    <aura:attribute name="options" type="List" default="[
                                                        { 'value': 'option1', 'label': 'Sales' },
                                                        { 'value': 'option2', 'label': 'Force' }
                                                        ]"/>
    <aura:attribute name="value" type="String" default="option1"/>
   
    <div class="slds-box slds-theme--default">      
        <lightning:radioGroup name="radioGroup"
                              label="Radio Group"
                              options="{! v.options }"
                              value="{! v.value }"
                              type="radio"/>
    </div>
   
</aura:component>

Output:


2 comments:

  1. Hi mag i dont want to use lightning:radiogroup is it possible to ui:inputradio and place the radio button infront of label.thanks.

    ReplyDelete
    Replies
    1. Don’t use ui tags. FYI - https://releasenotes.docs.salesforce.com/en-us/winter20/release-notes/rn_aura_ui_deprecate.htm

      Delete