Tutorials Blazor Architecture & Enterprise Patterns
Custom Component Libraries: Building for reuse
On this page
The Design System
In an enterprise, you don't build buttons and inputs from scratch every time. You build a **Razor Class Library (RCL)**.
1. Razor Class Libraries (RCLs)
An RCL is a specialized .NET project that can contain .razor files, CSS, Javascript, and static assets. It can be packed into a **NuGet** package and shared across all your company's apps. This ensures a consistent look and feel (your 'Design System') across your whole portfolio.
2. Static Assets and Isolation
Blazor supports **CSS Isolation**. You create a MyComponent.razor.css file, and the styles in that file ONLY apply to that component. This prevents 'Global CSS Pollution' and makes your library components much safer to use alongside other libraries.
3. Architect Insight
Q: "Should I wrap MudBlazor or Fluent UI?"
Architect Answer: "YES. Don't build a raw library from scratch. Choose a robust base like **MudBlazor** or **AntDesign Blazor**, and then create your OWN library that wraps their components with your company's styling, specific validation logic, and default properties. This gives you 90% productivity and 100% control over your UI standards."