Skip to content

Writing your own UI libraries

Static Components has been optimized for the usage of Razor Class Libraries. In fact, as a proof of concept, and for personal use, I wrote an implementation of DevDojo’s PinesUI by making it native to ASP.NET Core and utilizing all the quality of life features that Static Components allows you.

Razor Class Libraries are useful for creating UI component libraries meant to be reused, this can be a great way to isolate your UI-only components from your application’s presentation components.

Razor Class Libraries can be combined with your CSS library of choice to make UI elements easier to use.

This is just a summary of habits you will find useful when writing components that need to be maintained.

When using Razor Pages or MVC it is important to use ASP.NET Core official tag helpers for link generation, or making forms easier to work with, here are some tips that can make it easier to create your own custom link and form input components:

Tag HelperHow to integrateExample
asp-forUse the ModelExpression type as a property in your component.PinesInput example
asp-controller, asp-action, asp-pageCan be configured on custom Static Components for link generation.PinesSidebarLink code-behind and view

In general, maintaining ASP.NET Core conventions of usage will make your components better and more consistent for your users.