web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Format horizontal radi...
Power Pages
Unanswered

Format horizontal radio button

(0) ShareShare
ReportReport
Posted on by 40

Hi, 

 

I have implemented the horizontal radio button control using the manage meta data screen but I have received feedback that we need to make this control look more 'modern'.

 

I was wondering how can I change the size of the selection and style of the circular box? We want to have two big selection choices which change to green or red depending on the choice (yes or no)

 

Cheers, 

Categories:
I have the same question (0)
  • Verified answer
    Inogic Profile Picture
    1,135 Super User 2025 Season 2 on at

    Hi @wen90 ,

    As per our understanding, you are looking for a UI change for radio buttons in the portal, 

    Initially the Default radio button's UI look like the below screenshot, 

    Inogic_0-1684739686220.png

    We can convert the YES/NO  labels as buttons when the user will click on NO  The label background will be RED and Green for YES,

    Inogic_1-1684739719964.png

    To achieve the above UI, open the Code Editor and paste the CSS codes in the CSS file for the Page as per your element name, In our scenario the element names are as below you can change the as per your requirement.

     

    label[for = cr82c_cardtype_0]

    label[for = cr82c_cardtype_1]

    The CSS code should be written in the CSS file for the Respective Web page as shown in the below screenshot,

    Inogic_2-1684739741435.png

    /* hiding the Radio buttons */

    #cr82c_cardtype_0,

    #cr82c_cardtype_1{

        display: none;

    }

    /* Custom css for labels */

    label[for = cr82c_cardtype_0]{

        background-color: rgb(0,221,255);

        color: black;

        padding: 3px 7px;

        margin: 5px 8px;

        border-radius: 20px;

        cursor: pointer;

        transition: all 0.3s ease-in;

    }

    label[for = cr82c_cardtype_1]{

        background-color: rgb(0,221,255);

        color: black;

        padding: 3px 7px;

        margin: 5px 8px;

        border-radius: 20px;

        cursor: pointer;

        transition: all 0.3s ease-in;

    }

    label[for = cr82c_cardtype_0]:hover{

        background: red;

        color: white;

    }

    label[for = cr82c_cardtype_1]:hover{

        background: rgb(0, 171, 0);

        color: white;

    }

    Now we have to make these buttons clickable and interactive.

     

    When the user will click on the label which will run in the background will click the respective Radio button, and will also remove the applied CSS for another label, so we will update the Javascript file using Code Editor with below code lines.

    Using jQuery we can achieve this :

    $(document).ready(()=>{

        //by default card type is no hence

        $("label[for = cr82c_cardtype_0]").css("background-color","red")

        $("label[for = cr82c_cardtype_0]").css("color","white")

        //when yes

        $("label[for = cr82c_cardtype_1]").click(()=>{

            $("#cr82c_cardtype_1").prop("checked",true)    

            $("label[for = cr82c_cardtype_1]").css("background-color","rgb(0, 171, 0)")

           $("label[for = cr82c_cardtype_1]").css("color","white")

            //removing the no lable css

            $("label[for = cr82c_cardtype_0]").css("background-color","rgb(0,221,255)")

            $("label[for = cr82c_cardtype_0]").css("color","black")

        })

        //when no

        $("label[for = cr82c_cardtype_0]").click(()=>{

            $("#cr82c_cardtype_0").prop("checked",true)

            $("label[for = cr82c_cardtype_0]").css("background-color","red")

            $("label[for = cr82c_cardtype_0]").css("color","white")    

            //Removing the yes lable css

            $("label[for = cr82c_cardtype_1]").css("background-color","rgb(0,221,255)")

            $("label[for = cr82c_cardtype_1]").css("color","black")

        }) 

    })

     

    This results in full working custom buttons for Yes/No Radio Buttons,

    Inogic_3-1684739772564.png


    If this answer helps, please mark it as an Accepted Solution so it would help others to find the solution.


    Thanks!

    Inogic Professional Service Division

    An expert technical extension for your techno-functional business needs

    Power Platform/Dynamics 365 CRM

    Drop an email at crm@inogic.com

    Service:  http://www.inogic.com/services/ 

    Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/

  • wen90 Profile Picture
    40 on at

    @Inogic I just copied this into the CSS page but nothing happened. I went into visual studio from the page where the form is published. Is this right? Or is it on the list page?

     

    I got the labels ID's but couldn't find anything for the card ID's, how do I find these?

     

    Thanks so much for the help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard