I spent the last few months building BlazOrbit , a component library for Blazor. It's not the first of its kind —MudBlazor, Radzen and Blazorise already exist— so I had to answer a hard question from the start: why does this need to exist?
The answer turned out to be a set of architectural decisions I want to share, because each one taught me something about building UI frameworks that I didn't know before I started.
Lesson 1: CSS classes don't scale in libraries
The standard pattern in component libraries is class toggling:
<button class= "btn btn-primary btn-lg" > Click me </button>
Enter fullscreen mode
Exit fullscreen mode
I don't think this is developer-friendly, and there are several points worth making:
Name collisions : Your .btn-primary will clash with Bootstrap, Tailwind, or the consumer's own CSS.
Combinatorial explosion : A button can be small, large, disabled, loading, outlined, filled, errored, full-width, with ripple, without ripple...…