KNM.RazorComponents 0.5.9-alpha

Overview

This library provides a set of reusable Razor components designed to work seamlessly with Blazor and .NET MAUI Hybrid applications.
Each component supports isolated CSS and optional JavaScript assets to keep styles and behaviors encapsulated and easy to maintain.

Features

  • Reusable, strongly-typed Razor components for Blazor and MAUI Hybrid.
  • Isolated CSS per component to avoid style conflicts across the app.
  • Optional JS interop for advanced UI behavior (loaded via _content/KNM.RazorComponents/...).
  • Bootstrap-friendly markup and classes for rapid UI composition.

Installation

Install the package from your NuGet feed (private):

dotnet add package KNM.RazorComponents

Or via project file:

<ItemGroup>
   <PackageReference Include="KNM.RazorComponents" Version="1.0.0" />
</ItemGroup>

Setup

Add the library CSS to your wwwroot/index.html (Blazor WebAssembly) or Pages/_Host.cshtml (Blazor Server):

    <link rel="stylesheet" href="_content/KNM.RazorComponents/knm.razorcomponents.css" />

Input Types (KnmInputType)

Type Description
Checkbox Standard form-check checkbox control
Switch Bootstrap form-switch toggle switch
Select Dropdown <select> with List<Option<T>> support
Text Standard input type="text"
TextArea Multi-line <textarea> input
Password input type="password" with eye toggle + complexity validation
Email input type="email" with advanced OnBlur validation
Tel Telephone input type="tel"
Range Slider input type="range" with MinValue/MaxValue/Step
Date Date picker input type="date" (supports DateTime/DateTime?)
DateTime Local date & time picker input type="datetime-local" (supports DateTime/DateTime?)
Time Time picker input type="time" (supports TimeSpan/TimeSpan?)
Number Numeric input input type="number" (supports int, double, decimal, etc.)
Month Month/year picker input type="month" (supports DateTime/DateTime?, format yyyy-MM)
Week ISO week picker input type="week" (supports DateTime/DateTime?, format yyyy-Www)
Color HTML5 color picker input type="color"
File File upload input type="file"
Search Search field input type="search"
RadioButtonList Vertical radio button list with List<RadioButtonOption>
ButtonSelect Bootstrap dropdown button group with List<Option<T>>

The month and week types use HTML standard formats (yyyy-MM and yyyy-Www) to ensure browser compatibility and native validation.

Layout Types (LayoutType)

Type Description
Vertical Label above input (default)
Horizontal Label left / Input right (row col-sm-3 col-sm-9)
Floating Bootstrap form-floating modern labels
Outlined Material-style outlined inputs (empty)

Supporting Classes

Class Usage
Option<T> { T Id, string Value, bool Enabled } for Select/ButtonSelect
RadioButtonOption { string Value, string Label, bool Selected } for Radio lists

Special Parameters

Parameter Description
CompareFields + CompareTo Password confirmation matching
ComplexityCheck Real-time password strength validation
ShowDisabledOptions Display disabled options in Selects
LabelRight Checkbox/Switch label positioned on right side

Getting started

  1. Add the namespace to your _Imports.razor (or equivalent):
@using KNM.RazorComponents
  1. Use a basic text input component in a Blazor page:
@page "/example"

<EditForm Model="@model">
    <KNMInputs binding="@model.Name"
               CustomClass="outbound mt-4"
               Layout="LayoutType.Vertical"
               Size="KnmInputSize.Medium" />
</EditForm>

@code {
    private DemoModel model = new();
}

Attributes

[AttributeUsage(AttributeTargets.Property)]
public class KnmInputAttribute : Attribute
{
    public KnmInputType InputType { get; set; } = KnmInputType.Text;
    public string Label { get; set; } = string.Empty;
    public string Placeholder { get; set; } = string.Empty;
    public string HelperText { get; set; } = string.Empty;
    public bool ShowInGrid { get; set; } = true;             // Grid/Table view
    public string LookupObject { get; set; } = string.Empty; // Lookup reference
    public int Order { get; set; } = 0;                      // Visualization Order
}

[AttributeUsage(AttributeTargets.Property)]
public class KnmSelectOptionsAttribute : Attribute
{
    public Type? OptionsType { get; set; }
    public string ValueProperty { get; set; } = "Id";
    public string LabelProperty { get; set; } = "Value";
}

Example model with attributes

public class DemoModel
{
    [KnmInput(ShowInGrid = false)]
    public int Id { get; set; }

    [Required]
    [KnmInput(InputType = KnmInputType.Text,
              Label = "Full name",
              Placeholder = "Enter your Name",
              Order = 1)]
    public string Name { get; set; } = string.Empty;

    [Required]
    [KnmInput(InputType = KnmInputType.Password,
              Label = "Password",
              Placeholder = "Enter your Password",
              HelperText = "The password should be 12 digits, Upper and lower letters and at least 1 special char",
              Order = 2)]
    public string Email { get; set; } = string.Empty;
}

No packages depend on KNM.RazorComponents.

.NET 10.0

Version Downloads Last updated
0.6.7-alpha 3 14/01/2026
0.6.6-alpha 1 14/01/2026
0.6.5-alpha 1 14/01/2026
0.6.4-alpha 1 14/01/2026
0.6.3-alpha 2 12/01/2026
0.5.9-alpha 1 05/01/2026
0.5.8-alpha 1 05/01/2026
0.5.7-alpha 1 05/01/2026
0.5.6-alpha 1 05/01/2026
0.5.5-alpha 1 05/01/2026
0.4.9-alpha 1 05/01/2026
0.4.8-alpha 1 05/01/2026
0.4.7-alpha 1 05/01/2026
0.4.6-alpha 1 05/01/2026
0.4.5-alpha 1 05/01/2026
0.3.9-alpha 2 09/12/2025
0.3.8-alpha 1 09/12/2025
0.3.7-alpha 1 09/12/2025
0.3.6-alpha 1 09/12/2025
0.3.5-alpha 1 09/12/2025
0.2.9-alpha 0 09/12/2025
0.2.8-alpha 1 09/12/2025
0.2.7-alpha 1 09/12/2025
0.2.6-alpha 1 09/12/2025
0.2.5-alpha 1 09/12/2025