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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

How to use bootstrap in Custom Visual?

I was trying to use the bootstrap for custom visual, but getting some error, the steps i did are

1- npm install bootstrap

2- using this line in visual.less

@import (less) "../node_modules/bootstrap/dist/css/bootstrap.css"
 
But I am getting the error on compilation.

The Error is 

ERROR in ./style/visual.less
Module build failed (from ../../Users/VCHA/AppData/Roaming/npm/node_modules/powerbi-visuals-tools/node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ../../Users/VCHA/AppData/Roaming/npm/node_modules/powerbi-visuals-tools/node_modules/less-loader/dist/cjs.js):


--bs-btn-padding-y: 0.375rem;
--bs-btn-font-family: ;
^
Unrecognised input.............

 

 

Please let me know how i can use the bootstrap in custom visual?

----Screenshot---

 
VivekChadha_0-1663657866685.png

 

1 ACCEPTED SOLUTION

Apologies - looks like Bootstrap 5 has some breaking changes from 4 (I haven't used it for a while in custom visuals).

It should work if you don't want to use less mixins (i.e. omit the (less) prefix). Using this in my visual.less works for me:

@import "~bootstrap/dist/css/bootstrap.css";

This seems to compile through webpack:

dmp_0-1663662342835.png

And, the classes are availabe in my visual's DOM:

dmp_1-1663662400355.png

Hopefully this should work for you too.

Good luck,

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)




View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Add bootstrap.css as an import directly in your visual.ts (I usually place it underneath the visual.less import). Bootstrap does not work with less.





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)




Anonymous
Not applicable

VivekChadha_0-1663661639002.png

Same issue is coming up even if i put the import in visual.ts

 

Apologies - looks like Bootstrap 5 has some breaking changes from 4 (I haven't used it for a while in custom visuals).

It should work if you don't want to use less mixins (i.e. omit the (less) prefix). Using this in my visual.less works for me:

@import "~bootstrap/dist/css/bootstrap.css";

This seems to compile through webpack:

dmp_0-1663662342835.png

And, the classes are availabe in my visual's DOM:

dmp_1-1663662400355.png

Hopefully this should work for you too.

Good luck,

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)




Hey @Anonymous - did this approach work for you?





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)




Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.