CsharpTags.Htmx
1.1.0-beta-2
This is a prerelease version of CsharpTags.Htmx.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package CsharpTags.Htmx --version 1.1.0-beta-2
NuGet\Install-Package CsharpTags.Htmx -Version 1.1.0-beta-2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CsharpTags.Htmx" Version="1.1.0-beta-2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CsharpTags.Htmx" Version="1.1.0-beta-2" />
<PackageReference Include="CsharpTags.Htmx" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CsharpTags.Htmx --version 1.1.0-beta-2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CsharpTags.Htmx, 1.1.0-beta-2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CsharpTags.Htmx@1.1.0-beta-2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CsharpTags.Htmx&version=1.1.0-beta-2&prerelease
#tool nuget:?package=CsharpTags.Htmx&version=1.1.0-beta-2&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CsharpTags.Htmx
A type-safe HTMX attribute library for C# that provides strongly-typed HTML attributes for HTMX functionality.
Overview
This library offers a type-safe way to work with HTMX attributes in C#, providing compile-time safety and IntelliSense support for all HTMX attributes and swap strategies. It's built on top of CsharpTags.Core and follows functional programming principles.
Installation
<PackageReference Include="CsharpTags.Htmx" Version="1.0.0-beta-3" />
Quick Start
using static CsharpTags.Core.Types.Prelude;
using static CsharpTags.Htmx.Types.Prelude;
// Create an element with HTMX attributes
var button = Button.Attr(
HxPost << "/api/update",
HxTarget << "#result",
HxSwap << SwapStrategy.InnerHTML,
).Child(
"Update Content"
);
// Use with target helpers
var form = Form.Attr(
HxPost << "/submit",
HxTargetClosest("tr"),
HxSwap << SwapStrategy.OuterHTML,
).Child(
// ... form content
).;
Core Attributes
HTTP Methods
HxGet- GET requestsHxPost- POST requestsHxPut- PUT requestsHxPatch- PATCH requestsHxDelete- DELETE requests
Target Selection
HxTargetThis // Target the current element
HxTargetClosest("tr") // Target closest table row
HxTargetFind(".error") // Find first child matching selector
HxTargetNext(".item") // Target next sibling matching selector
HxTargetPrevious(".item") // Target previous sibling matching selector
Swap Modifiers
// Add modifiers to swap strategies
HxSwap << SwapStrategy.InnerHTML + "swap:1s"
HxSwap << SwapStrategy.OuterHTML.Modify("transition:true")
Advanced Features
Synchronization Strategies
HxSyncDrop("#form") // Drop if request in flight
HxSyncAbort("#form") // Abort on new request
HxSyncReplace("#form") // Replace current request
HxSyncQueue("#form") // Add to queue
HxSyncQueueFirst("#form") // Add to front of queue
HxSyncQueueLast("#form") // Add to end of queue
HxSyncQueueAll("#form") // Queue all requests
Event Handling
HxOnClick << "alert('Clicked!')"
HxOnSubmit << "validateForm()"
HxOnChange << "updatePreview()"
HxOnKeyUp << "search()"
// Or create custom event handlers
HxOn("custom-event") << "handleCustom()"
Form Enhancements
HxBoost << true // Boost links and forms
HxValidate << true // Validate before submit
HxConfirm << "Are you sure?" // Confirmation dialog
HxPrompt << "Enter value:" // Prompt for input
Complete Example
using static CsharpTags.Core.Types.Prelude;
using static CsharpTags.Htmx.Types.Prelude;
var userInterface = Div.Child(
// Search with debouncing
Input.Attr(
Type_ << "text",
HxGet << "/api/search",
HxTrigger << "keyup changed delay:500ms",
HxTarget << "#results",
Placeholder << "Search users..."
),
// Results area
Div.Attr(id_ << "results"),
// Update user form
Form.Attr(
HxPut << "/api/users/1",
HxTargetClosest("tr"),
HxSwap << SwapStrategy.OuterHTML + "transition:true",
).Child(
Input.Attr(Type_ << "text", Name << "username", Value << "john_doe"),
Button.Attr(HxOnClick << "this.closest('form').requestSubmit()")
.Child("Save")
)
);
Requirements
- .NET 10.0 or later
- CsharpTags.Core package
- HTMX library in your frontend
Links
License
MIT License - see LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- CsharpTags.Core (>= 1.1.0-beta-2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0-beta-4 | 55 | 3/7/2026 |
| 1.1.0-beta-3 | 62 | 2/15/2026 |
| 1.1.0-beta-2 | 59 | 2/2/2026 |
| 1.1.0-beta-1 | 70 | 1/6/2026 |
| 1.0.0-beta-5 | 418 | 12/10/2025 |
| 1.0.0-beta-4 | 414 | 12/9/2025 |
| 1.0.0-beta-3 | 159 | 11/26/2025 |
| 1.0.0-beta-2 | 172 | 11/25/2025 |