Skip to content

ASP.NET Core library providing HTMX-enabled UI components for interactive server-side web applications

License

Notifications You must be signed in to change notification settings

ucdavis/Htmx.Components

Repository files navigation

Htmx.Components

NuGet Documentation License: MIT

A comprehensive ASP.NET Core library for building interactive web applications with server-side rendering and HTMX integration. Get dynamic UIs with minimal JavaScript through reusable components, state management, and built-in authorization.

✨ What You Get

  • 🚀 Ready-to-use components: Tables, navigation, auth status, forms
  • 🔧 HTMX integration: Out-of-band updates, multi-swap responses, page state
  • 🛡️ Authorization system: Resource-based permissions with ASP.NET Core integration
  • 📱 Responsive design: Built for DaisyUI/Tailwind CSS
  • Automatic partial updates: Smart filters handle HTMX updates behind the scenes

🚀 Quick Example

// Program.cs - Minimal setup
builder.Services.AddHtmxComponents();
builder.Services.AddControllersWithViews()
    .AddHtmxComponentsApplicationPart();

app.UseHtmxPageState();
app.UseAuthentication();
app.UseAuthorization();
// Controllers - Attribute-based navigation and tables
[NavActionGroup(DisplayName = "Admin")]
public class AdminController : Controller
{
    [NavAction(DisplayName = "Users", Icon = "fas fa-users")]
    public async Task<IActionResult> Users()
    {
        var tableModel = await _modelHandler.BuildTableModelAsync();
        // Note that we are returning an ObjectResult here rather than a ViewResult.
        // Htmx.Components makes use of result filters and action context to determine whether to return
        // a ViewResult or a htmx-specific MultiSwapViewResult. For htmx requests, filters determine
        // what partial views and models go into building the response.
        return Ok(tableModel);
    }
}
<!-- Layout - Components just work -->
@await Component.InvokeAsync("NavBar")
@await Component.InvokeAsync("AuthStatus")
@await Component.InvokeAsync("Table", Model)

<htmx-scripts></htmx-scripts> <!-- JavaScript behaviors -->
<htmx-page-state></htmx-page-state> <!-- State management -->

Result: Dynamic navigation, interactive tables, auth integration - all with server-side rendering.

📖 Documentation

Guide Description
🚀 Getting Started Installation, setup, and first working example
👤 User Guide Usage patterns, components, and examples
🔧 Developer Guide Architecture, extension points, and customization
📚 API Reference Complete API documentation

💻 Requirements

  • .NET 8.0+
  • ASP.NET Core
  • HTMX 2.0+

🤝 Contributing

Contributions welcome! See our Contributing Guide for development setup and guidelines.

📄 License

MIT License - see LICENSE file for details.

About

ASP.NET Core library providing HTMX-enabled UI components for interactive server-side web applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published