Class HtmxV2Config
- Namespace
- Ramstack.HtmxToolkit.Configuration
- Assembly
- Ramstack.HtmxToolkit.dll
Represents the configuration for HTMX 2.x.
public sealed class HtmxV2Config : HtmxConfig
- Inheritance
-
HtmxV2Config
- Inherited Members
Properties
AddedClass
Gets or sets the class added to new content before it is swapped in
and removed after the content settles.
The HTMX default is htmx-added.
public string? AddedClass { get; set; }
Property Value
AllowEval
Gets or sets a value indicating whether the use of eval is allowed.
The HTMX default is true.
public bool? AllowEval { get; set; }
Property Value
- bool?
AllowNestedOobSwaps
Gets or sets a value indicating whether out-of-band swaps nested in the main response are processed. The HTMX default is true.
public bool? AllowNestedOobSwaps { get; set; }
Property Value
- bool?
AllowScriptTags
Gets or sets a value indicating whether <script> tags should be processed in new content.
The HTMX default is true.
public bool? AllowScriptTags { get; set; }
Property Value
- bool?
AttributesToSettle
Gets or sets the attributes to settle during the settling phase.
The HTMX default is ["class", "style", "width", "height"].
public IReadOnlyList<string>? AttributesToSettle { get; set; }
Property Value
DefaultFocusScroll
Gets or sets a value indicating whether the focused element should be scrolled into view. The HTMX default is false.
public bool? DefaultFocusScroll { get; set; }
Property Value
- bool?
Remarks
The focus-scroll swap modifier overrides this setting.
DefaultSettleDelay
Gets or sets the default settle delay in milliseconds.
The HTMX default is 20.
public int? DefaultSettleDelay { get; set; }
Property Value
- int?
DefaultSwapDelay
Gets or sets the default swap delay in milliseconds.
The HTMX default is 0.
public int? DefaultSwapDelay { get; set; }
Property Value
- int?
DefaultSwapStyle
Gets or sets the default swap style. The HTMX default is InnerHtml.
[JsonConverter(typeof(HtmxSwapJsonConverter))]
public HtmxSwap? DefaultSwapStyle { get; set; }
Property Value
DisableInheritance
Gets or sets a value indicating whether attribute inheritance is disabled. The HTMX default is false.
public bool? DisableInheritance { get; set; }
Property Value
- bool?
DisableSelector
Gets or sets the selector for elements that HTMX must not process.
The HTMX default is [hx-disable], [data-hx-disable].
public string? DisableSelector { get; set; }
Property Value
GetCacheBusterParam
Gets or sets a value indicating whether GET requests use a cache-busting parameter.
The HTMX default is false.
public bool? GetCacheBusterParam { get; set; }
Property Value
- bool?
GlobalViewTransitions
Gets or sets a value indicating whether the View Transition API should be used for swaps. The HTMX default is false.
public bool? GlobalViewTransitions { get; set; }
Property Value
- bool?
HistoryCacheSize
Gets or sets the size of the history cache.
The HTMX default is 10.
public int? HistoryCacheSize { get; set; }
Property Value
- int?
HistoryEnabled
Gets or sets a value indicating whether HTMX history support is enabled. The HTMX default is true.
public bool? HistoryEnabled { get; set; }
Property Value
- bool?
HistoryRestoreAsHxRequest
Gets or sets a value indicating whether history cache-miss requests are marked as HTMX requests. The HTMX default is true.
public bool? HistoryRestoreAsHxRequest { get; set; }
Property Value
- bool?
Remarks
Available since HTMX 2.0.5.
IgnoreTitle
Gets or sets a value indicating whether document titles found in new content are ignored. The HTMX default is false.
public bool? IgnoreTitle { get; set; }
Property Value
- bool?
IncludeIndicatorStyles
Gets or sets a value indicating whether the indicator styles are loaded. The HTMX default is true.
public bool? IncludeIndicatorStyles { get; set; }
Property Value
- bool?
IndicatorClass
Gets or sets the class that marks request indicators.
The HTMX default is htmx-indicator.
public string? IndicatorClass { get; set; }
Property Value
Remarks
The indicator styles show these elements only while they or one of their ancestors have the class specified by RequestClass.
InlineScriptNonce
Gets or sets the nonce added to inline scripts. The HTMX default is an empty string.
public string? InlineScriptNonce { get; set; }
Property Value
InlineStyleNonce
Gets or sets the nonce added to inline styles. The HTMX default is an empty string.
public string? InlineStyleNonce { get; set; }
Property Value
MethodsThatUseUrlParams
Gets or sets the HTTP methods that use URL parameters.
The HTMX default is ["get", "delete"].
[JsonConverter(typeof(HtmxHttpVerbListJsonConverter))]
public IReadOnlyList<HtmxHttpVerb>? MethodsThatUseUrlParams { get; set; }
Property Value
RefreshOnHistoryMiss
Gets or sets a value indicating whether a history miss causes a full-page refresh instead of an AJAX request. The HTMX default is false.
public bool? RefreshOnHistoryMiss { get; set; }
Property Value
- bool?
ReportValidityOfForms
Gets or sets a value indicating whether form validity is reported before a request is issued. The HTMX default is false.
public bool? ReportValidityOfForms { get; set; }
Property Value
- bool?
Remarks
Available since HTMX 2.0.7.
RequestClass
Gets or sets the class added to the elements specified by hx-indicator,
or to the requesting element itself, while a request is in flight.
The HTMX default is htmx-request.
public string? RequestClass { get; set; }
Property Value
ResponseHandling
Gets or sets the rules that determine how HTTP response status codes are handled.
The HTMX default is [{ code: "204", swap: false }, { code: "[23]..", swap: true },
{ code: "[45]..", swap: false, error: true }].
public IReadOnlyList<HtmxResponseHandlingOptions>? ResponseHandling { get; set; }
Property Value
Examples
options.UseHtmxV2(config =>
{
// Assigning the list replaces the HTMX defaults, so the rules repeat them
// and add one more: swap validation forms returned with status 422.
config.ResponseHandling =
[
new() { Code = "204", Swap = false },
new() { Code = "[23]..", Swap = true },
new() { Code = "422", Swap = true, Error = false },
new() { Code = "[45]..", Swap = false, Error = true }
];
});
ScrollBehavior
Gets or sets the scrolling behavior used by the show modifier of hx-swap.
The HTMX default is Instant.
[JsonConverter(typeof(HtmxScrollBehaviorJsonConverter))]
public HtmxScrollBehavior? ScrollBehavior { get; set; }
Property Value
ScrollIntoViewOnBoost
Gets or sets a value indicating whether boosted targets are scrolled into the viewport. The HTMX default is true.
public bool? ScrollIntoViewOnBoost { get; set; }
Property Value
- bool?
SelfRequestsOnly
Gets or sets a value indicating whether requests are restricted to the current origin. The HTMX default is true.
public bool? SelfRequestsOnly { get; set; }
Property Value
- bool?
SettlingClass
Gets or sets the class added to the target after content is swapped
and removed after the content settles.
The HTMX default is htmx-settling.
public string? SettlingClass { get; set; }
Property Value
SwappingClass
Gets or sets the class added to the target before content is swapped
and removed after the swap.
The HTMX default is htmx-swapping.
public string? SwappingClass { get; set; }
Property Value
Timeout
Gets or sets the request timeout in milliseconds.
The HTMX default is 0.
public int? Timeout { get; set; }
Property Value
- int?
TriggerSpecsCacheEnabled
Gets or sets a value indicating whether parsed trigger specifications use a never-clearing cache. The HTMX default is false.
[JsonConverter(typeof(HtmxTriggerSpecsCacheJsonConverter))]
[JsonPropertyName("triggerSpecsCache")]
public bool? TriggerSpecsCacheEnabled { get; set; }
Property Value
- bool?
WithCredentials
Gets or sets a value indicating whether credentials are included in cross-origin requests. The HTMX default is false.
public bool? WithCredentials { get; set; }
Property Value
- bool?
WsBinaryType
Gets or sets the type of binary data received over WebSocket connections. The HTMX default is Blob.
[JsonConverter(typeof(HtmxBinaryTypeJsonConverter))]
public HtmxBinaryType? WsBinaryType { get; set; }
Property Value
Remarks
Requires the HTMX WebSocket extension.