Class HtmxV4Config
- Namespace
- Ramstack.HtmxToolkit.Configuration
- Assembly
- Ramstack.HtmxToolkit.dll
Represents the configuration for HTMX 4.x.
public sealed class HtmxV4Config : HtmxConfig
- Inheritance
-
HtmxV4Config
- Inherited Members
Properties
AllowEmptySwapAfterOob
Gets or sets a value indicating whether the main swap is performed when no content remains after processing out-of-band elements. The HTMX default is false.
[JsonPropertyName("allowEmptySwapAfterOOB")]
public bool? AllowEmptySwapAfterOob { get; set; }
Property Value
- bool?
Remarks
Processed <hx-partial> elements suppress an empty main swap regardless
of this setting. The swapEmpty modifier on hx-swap takes precedence in both cases.
Non-empty main content is still swapped, and the Delete swap style always runs.
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 1.
public int? DefaultSettleDelay { get; set; }
Property Value
- int?
DefaultSwap
Gets or sets the default swap style. The HTMX default is InnerHtml.
[JsonConverter(typeof(HtmxSwapJsonConverter))]
public HtmxSwap? DefaultSwap { get; set; }
Property Value
DefaultTimeout
Gets or sets the default request timeout in milliseconds.
The HTMX default is 60000.
public int? DefaultTimeout { get; set; }
Property Value
- int?
Extensions
Gets or sets a comma-separated list of extensions that HTMX is allowed to register. The HTMX default is an empty string, which allows all extensions.
public string? Extensions { get; set; }
Property Value
Remarks
HTMX compares extension names exactly. Whitespace is allowed only after a comma;
any other whitespace becomes part of a name, so "sse ,ws" does not allow sse.
History
Gets or sets how HTMX history restoration is handled. The HTMX default is Enabled.
[JsonConverter(typeof(HtmxHistoryModeJsonConverter))]
public HtmxHistoryMode? History { get; set; }
Property Value
ImplicitInheritance
Gets or sets a value indicating whether HTMX attributes are inherited implicitly. The HTMX default is false.
public bool? ImplicitInheritance { get; set; }
Property Value
- bool?
IncludeIndicatorCss
Gets or sets a value indicating whether the indicator styles are loaded. The HTMX default is true.
[JsonPropertyName("includeIndicatorCSS")]
public bool? IncludeIndicatorCss { 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 undefined, which means that no nonce is added.
public string? InlineScriptNonce { get; set; }
Property Value
LogAll
Gets or sets a value indicating whether all HTMX events are logged to the console. The HTMX default is false.
public bool? LogAll { get; set; }
Property Value
- bool?
Mode
Gets or sets the request mode passed to the Fetch API. The HTMX default is SameOrigin.
[JsonConverter(typeof(HtmxRequestModeJsonConverter))]
public HtmxRequestMode? Mode { get; set; }
Property Value
MorphIgnore
Gets or sets the attribute name prefixes to preserve during morphing.
The HTMX default is ["data-htmx-powered"].
public IReadOnlyList<string>? MorphIgnore { get; set; }
Property Value
MorphScanLimit
Gets or sets the maximum number of siblings scanned while matching elements during morphing.
The HTMX default is 10.
public int? MorphScanLimit { get; set; }
Property Value
- int?
MorphSkip
Gets or sets the selector for elements to skip during morphing.
The HTMX default is [hx-morph-skip].
public string? MorphSkip { get; set; }
Property Value
MorphSkipChildren
Gets or sets the selector for elements whose children should not be morphed.
The HTMX default is [hx-morph-skip-children].
public string? MorphSkipChildren { get; set; }
Property Value
NoSwap
Gets or sets the response status codes or patterns for which HTMX does not perform a swap.
The HTMX default is [204, 304].
public IReadOnlyList<string>? NoSwap { get; set; }
Property Value
Examples
options.UseHtmxV4(config =>
{
// Keep the page unchanged on server errors, but still swap 4xx responses
// such as 422 validation forms. Assigning the list replaces the HTMX default,
// ["204", "304"], so the list repeats it.
config.NoSwap = ["204", "304", "5xx"];
});
Remarks
Although HTMX declares this option as a number array, it converts each entry to a string
at runtime and supports wildcard patterns such as "4xx" and "44x".
Prefix
Gets or sets the secondary attribute prefix recognized alongside hx-*.
The HTMX default is data-hx-.
public string? Prefix { get; set; }
Property Value
Remarks
An empty string disables the secondary prefix, so HTMX reads only hx-. This helps when the application
renders user-supplied HTML through a sanitizer that allows data- attributes,
which would otherwise let data-hx-* attributes reach HTMX.
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
Transitions
Gets or sets a value indicating whether the View Transition API should be used when swapping in new content. The HTMX default is false.
public bool? Transitions { get; set; }
Property Value
- bool?