Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Andrew_lu1933
Regular Visitor

Use Html content<input type=radio> visual to build a slicer, how to get slicer function。

In power bi desktop,  we can't setting the input radio color, I want to use html <input type=radio> and css to get custom style.

it display the custom select element, but how can get the slicer function.

 

Month = 
AddColumns(
    values('Date'[Month]),
    "Html_month",
    var month_r = Format([Month],"Mmm-yy")
    var before_str = "<label><input type='radio' name='month'><span>"
    var after_str = "</span></label>"
    return before_str & month_r & after_str
)
css_month = "<style>
            * {
                padding: 0;
                margin: 0;
                box-sizing: border-box;
            }

            label {
                position: relative;
                height: 30px;
                line-height: 30px;
                padding-left: 10px;
            }
            label>span{
                margin-left: 12px;color:#FFEFD5;
            }

            input[type=radio] {
                visibility: hidden;
                height: 30px;
                margin-left: .2rem;

            }

            input[type=radio]:checked::before {
                background: #2957FF;
                visibility: visible;
            }

            input[type=radio]::before {
                content: '';
                position: absolute;
                margin-top: 15px;
                margin-left: 2px;
                height: 16px;
                width: 16px;
                border-radius: 50%;
                background-color: rgba(152,251,152,0.2);
                visibility: visible;
                z-index: 2;
            }

            input[type=radio]::after {
                content: '';
                position: absolute;
                height: 20px;
                width: 20px;
                margin-top: 13px;
                border-radius: 50%;
                background-color: transparent;
                border: 2px solid #FFF8DC;
                visibility: visible;
                z-index: -1;
            }
        </style>"

 

 

Andrew_lu1933_0-1675836685222.png

 

 

2 REPLIES 2
dm-p
Super User
Super User

Hi @Andrew_lu1933,

HTML Content does not support JavaScript, or include any of the JavaScript APIs necessary for building custom visuals using the TypeScript SDK.

If you're looking to build a functional slicer, please refer to the documentation for developing a custom visual here. Once you are familiar with the concepts required, you can look at setting up and using the filter API to ensure that your visual works as a slicer.

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




KerKol
Power Participant
Power Participant

Frequently Asked Questions | HTML Content - Custom Visual for Power BI (html-content.com)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.