How to use bootstrap in blazor component library efficiently

Viewed 34

I recently migrated my custom components from my blazor app to a blazor component library so that I could use them in other projects. The problem is that the blazor component library does not have bootstrap, thus when I pass class parameters from the app side, they do not function.

for instance :

<MyComponent Class="mt-5" /> 

In this case, there will be no top margin.

Of course, linking the bootstrap.min.css file to each component would work. I'm not a frontend developer and have little experience with this, so I'm wondering whether this would cause performance issues because the bootstrap file will be loaded for each component independently each time.

So my question is if this is a bad approach. If so, what are my alternatives?

Edit:

The component name is not actually MyComponent; I typed it down for convenience.

I'm actually adding some features on Mudblazor components..

<MudSelect Class="@class" />

where I define class as a string property

[Parameter]
public string Class { get; set; }
0 Answers
Related