Chd.AutoUI
8.0.0
See the version list below for details.
dotnet add package Chd.AutoUI --version 8.0.0
NuGet\Install-Package Chd.AutoUI -Version 8.0.0
<PackageReference Include="Chd.AutoUI" Version="8.0.0" />
<PackageVersion Include="Chd.AutoUI" Version="8.0.0" />
<PackageReference Include="Chd.AutoUI" />
paket add Chd.AutoUI --version 8.0.0
#r "nuget: Chd.AutoUI, 8.0.0"
#:package Chd.AutoUI@8.0.0
#addin nuget:?package=Chd.AutoUI&version=8.0.0
#tool nuget:?package=Chd.AutoUI&version=8.0.0
Chd.AutoUI โ Attribute-Driven UI Metadata for .NET
Chd (Cleverly Handle Difficulty) AutoUI helps you cleverly handle UI complexity, write less code, and keep your application maintainable. It enables rapid, type-safe, and maintainable UI development by generating rich metadata from C# attributes. Build dynamic forms and grids for your frontend with zero JavaScript or manual JSON.
๐ Table of Contents
About
Chd.AutoUI is a .NET library that lets you define UI structure, validation, and behavior directly in your C# DTOs using attributes. It generates JSON metadata for dynamic UI rendering in any frontend framework.
Features
- Attribute-driven:
[AutoCRUD],[GridColumn],[FormField] - 12+ field types: text, number, date, dropdown, multiselect, file, etc.
- Type-safe, reflection-based metadata
- Works with any frontend (React, Vue, Angular, Blazor)
- Extensible: add custom field types/attributes
- Minimal configuration, rapid prototyping
Installation
dotnet add package Chd.AutoUI
Usage
C# Metadata Generation
using Chd.AutoUI.Attributes;
[AutoCRUD(Title = "Products", Icon = "๐ฆ", Route = "/products", Description = "Product management")]
public class ProductDto
{
[GridColumn(Order = 1, Width = 80)]
[FormField(ReadOnly = true)]
public int Id { get; set; }
[GridColumn(Order = 2, Width = 200)]
[FormField(Label = "Product Name", Type = FieldType.Text, Required = true, MaxLength = 250, Order = 1)]
public string Name { get; set; } = string.Empty;
[GridColumn(Order = 3, Width = 150, Format = "currency")]
[FormField(Label = "Price", Type = FieldType.Number, Required = true, Order = 2)]
public decimal Price { get; set; }
[GridColumn(Order = 4, Width = 100)]
[FormField(Label = "Active", Type = FieldType.Checkbox, Order = 3)]
public bool IsActive { get; set; }
}
using Chd.AutoUI.Attributes;
using Chd.AutoUI.Services;
[AutoCRUD(Title = "Products", Icon = "๐ฆ", Route = "/products")]
public class ProductDto
{
[GridColumn(Order = 1, Width = 80)]
[FormField(Label = "Product Name", Type = FieldType.Text, Required = true, MaxLength = 250, Order = 1)]
public string Name { get; set; } = string.Empty;
[GridColumn(Order = 2, Width = 150, Format = "currency")]
[FormField(Label = "Price", Type = FieldType.Number, Required = true, Order = 2)]
public decimal Price { get; set; }
}
// Generate metadata
var generator = new MetadataGenerator();
var metadata = generator.GenerateMetadata<ProductDto>();
var json = JsonSerializer.Serialize(metadata);
API Endpoint Example
[ApiController]
[Route("api/[controller]")]
public class MetadataController : ControllerBase
{
[HttpGet("metadata")]
public IActionResult GetMetadata() => Ok(MetadataGenerator.GenerateMetadata<ProductDto>());
}
React Integration
Use the official React package for instant UI generation:
npm install @mehmetyoldas/chd-auto-ui-react
import { DynamicForm, DynamicGrid } from '@mehmetyoldas/chd-auto-ui-react';
function ProductManager() {
return (
<>
<DynamicForm apiUrl="/api/products" metadataUrl="/api/products/metadata" />
<DynamicGrid apiUrl="/api/products" metadataUrl="/api/products/metadata" />
</>
);
}
See React package documentation for full details.
Attribute Reference
[AutoCRUD] (class)
Defines entity-level UI settings (title, icon, route, description).
[GridColumn] (property)
Defines grid/table columns (order, width, format, sortable, hidden).
[FormField] (property)
Defines form fields (label, type, required, maxLength, placeholder, order, readOnly).
Supported Field Types:
- Text, Number, Email, Password, TextArea, Date, DateTime, Checkbox, Select, MultiSelect, Radio, File
Roadmap / To-Do
- React integration (DynamicForm, DynamicGrid)
- Vue.js support (planned)
- Angular support (planned)
- Blazor support (planned)
- Svelte support (planned)
- Custom field type extensibility (advanced)
- Improved validation and localization
- More UI frameworks and themes
- Advanced grid features (grouping, export, etc.)
- Better documentation and samples
Contributing & License
Contributions are welcome! Please open issues or pull requests for bugfixes, features, or documentation.
Licensed under the MIT License.
๐ Attributes
AutoCRUDAttribute
Defines general UI settings for the entity.
[AutoCRUD(
Title = "Products", // Title displayed in UI
Icon = "๐ฆ", // Icon (emoji or icon class)
Route = "/products", // Frontend route
Description = "Product list" // Description
)]
public class ProductDto { }
GridColumnAttribute
Defines grid/table columns.
[GridColumn(
Order = 1, // Sort order
Width = 150, // Width in pixels
Sortable = true, // Is sortable?
Format = "currency", // Format type: "currency", "date", "percent", "number"
Hidden = false // Is hidden?
)]
public decimal Price { get; set; }
Format Types:
currency: Currency format (e.g., $1,234.56)date: Date format (e.g., 01/15/2024)percent: Percentage format (e.g., 75%)number: Number format (e.g., 1,234.56)
FormFieldAttribute
Defines form fields.
[FormField(
Label = "Product Name", // Form label
Type = FieldType.Text, // Field type
Required = true, // Is required?
MaxLength = 250, // Maximum length
Placeholder = "Enter name", // Placeholder text
Order = 1, // Form order
ReadOnly = false // Is read-only?
)]
public string Name { get; set; }
Field Types:
Text: Text inputNumber: Number inputEmail: Email inputPassword: Password inputTextarea: Multi-line textDate: Date pickerCheckbox: CheckboxSelect: Dropdown listFile: File upload
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ C# DTO Classes โ
โ [AutoCRUD] [GridColumn] [FormField] โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MetadataGenerator (Reflection) โ
โ - ScanAssemblyForEntities() โ
โ - GenerateMetadata<T>() โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ JSON Metadata (REST API) โ
โ GET /api/metadata โ
โ GET /api/metadata/{entityName} โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Frontend (React/Vue/Angular) โ
โ - DynamicGrid Component โ
โ - DynamicForm Component โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ JSON Metadata Format
{
"entityName": "ProductDto",
"title": "Products",
"icon": "๐ฆ",
"route": "/products",
"description": "Product management",
"grid": {
"columns": [
{
"propertyName": "Id",
"title": "Id",
"type": "number",
"order": 1,
"width": 80,
"sortable": true,
"format": null,
"hidden": false
},
{
"propertyName": "Name",
"title": "Name",
"type": "string",
"order": 2,
"width": 200,
"sortable": true,
"format": null,
"hidden": false
}
]
},
"form": {
"fields": [
{
"propertyName": "Name",
"label": "Product Name",
"type": "text",
"required": true,
"maxLength": 250,
"placeholder": "Enter name",
"order": 1,
"readOnly": false
}
]
}
}
๐ง Advanced Usage
Assembly Scanning
To automatically discover all DTOs:
var generator = new MetadataGenerator();
var assembly = typeof(ProductDto).Assembly;
var allEntities = generator.ScanAssemblyForEntities(assembly);
// allEntities: metadata for all classes with [AutoCRUD] attribute
Adding Custom Field Types
You can extend the FieldType enum to add your own field types:
public enum CustomFieldType
{
// Standard types
Text = 0,
Number = 1,
// ...
// Custom types
RichTextEditor = 100,
ColorPicker = 101,
ImageUploader = 102
}
๐งช Test Examples
Simple Entity
[AutoCRUD(Title = "Categories", Icon = "๐", Route = "/categories")]
public class CategoryDto
{
[GridColumn(Order = 1, Width = 80)]
[FormField(ReadOnly = true)]
public int Id { get; set; }
[GridColumn(Order = 2, Width = 200)]
[FormField(Label = "Category Name", Type = FieldType.Text, Required = true, MaxLength = 100, Order = 1)]
public string Name { get; set; } = string.Empty;
}
Related Entity
[AutoCRUD(Title = "Products", Icon = "๐ฆ", Route = "/products")]
public class ProductDto
{
[GridColumn(Order = 1, Width = 80)]
[FormField(ReadOnly = true)]
public int Id { get; set; }
[GridColumn(Order = 2, Width = 200)]
[FormField(Label = "Product Name", Type = FieldType.Text, Required = true, Order = 1)]
public string Name { get; set; } = string.Empty;
[GridColumn(Order = 3, Width = 150)]
[FormField(Label = "Category", Type = FieldType.Select, Required = true, Order = 2)]
public int CategoryId { get; set; }
[GridColumn(Order = 4, Width = 150)]
public string? CategoryName { get; set; }
}
๐ ๏ธ Technologies
- .NET 8.0
- System.Reflection - For metadata generation
- Microsoft.EntityFrameworkCore - For entity support
๐ Frontend Integration
React Components (npm)
For automatic UI generation in React, use our companion npm package:
npm install @mehmetyoldas/chd-auto-ui-react
Complete Integration Example:
// 1. Backend: C# DTO with attributes
[AutoCRUD(Title = "Products", Icon = "๐ฆ")]
public class ProductDto
{
[GridColumn(Order = 1)] [FormField(Type = FieldType.Text)]
public int Id { get; set; }
[GridColumn(Order = 2)] [FormField(Type = FieldType.Text, Required = true)]
public string Name { get; set; }
}
// 2. API Controller
[HttpGet("metadata")]
public IActionResult GetMetadata() => Ok(MetadataGenerator.GenerateMetadata<ProductDto>());
// 3. Frontend: React components
import { DynamicForm, DynamicGrid } from '@mehmetyoldas/chd-auto-ui-react';
function ProductManager() {
return (
<div>
<DynamicForm
apiUrl="/api/products"
metadataUrl="/api/products/metadata"
/>
<DynamicGrid
apiUrl="/api/products"
metadataUrl="/api/products/metadata"
/>
</div>
);
}
๐ React Package Documentation: npm package
๐ License
MIT License
๐ค Contributing
- Fork the project
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ Contact
Chd Framework - metadata-driven UI generation
๐ Related Projects
- Chd.AutoUI.EF - Generic Repository Pattern
- Chd.Pos - POS Demo Application
- Chd.StockTracking - Stock Tracking Demo Application
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.