HtmxConfig

@Serializable
data class HtmxConfig(val historyEnabled: Boolean? = null, val historyCacheSize: Int? = null, val refreshOnHistoryMiss: Boolean? = null, val defaultSwapStyle: HxSwap? = null, val defaultSwapDelay: Duration? = null, val defaultSettleDelay: Duration? = null, val includeIndicatorStyles: Boolean? = null, val indicatorClass: String? = null, val requestClass: String? = null, val addedClass: String? = null, val settlingClass: String? = null, val swappingClass: String? = null, val allowEval: Boolean? = null, val allowScriptTags: Boolean? = null, val inlineScriptNonce: String? = null, val attributesToSettle: Collection<String>? = null, val wsReconnectDelay: String? = null, val wsBinaryType: WsBinaryType? = null, val disableSelector: List<String>? = null, val withCredentials: Boolean? = null, val timeout: Duration? = null, val scrollBehavior: HxScrollBehaviour? = null, val defaultFocusScroll: Boolean? = null, val getCacheBusterParam: Boolean? = null, val globalViewTransitions: Boolean? = null, val methodsThatUseUrlParams: Collection<HttpVerb>? = null, val selfRequestsOnly: Boolean? = null, val ignoreTitle: Boolean? = null, val scrollIntoViewOnBoost: Boolean? = null, val triggerSpecsCache: String? = null, val allowNestedOobSwaps: Boolean? = null, val responseHandling: Collection<HtmxConfig.ResponseHandling>? = null)(source)

Htmx has some configuration options that can be accessed either programmatically or declaratively.

See Configuration Reference.

Constructors

Link copied to clipboard
constructor(historyEnabled: Boolean? = null, historyCacheSize: Int? = null, refreshOnHistoryMiss: Boolean? = null, defaultSwapStyle: HxSwap? = null, defaultSwapDelay: Duration? = null, defaultSettleDelay: Duration? = null, includeIndicatorStyles: Boolean? = null, indicatorClass: String? = null, requestClass: String? = null, addedClass: String? = null, settlingClass: String? = null, swappingClass: String? = null, allowEval: Boolean? = null, allowScriptTags: Boolean? = null, inlineScriptNonce: String? = null, attributesToSettle: Collection<String>? = null, wsReconnectDelay: String? = null, wsBinaryType: WsBinaryType? = null, disableSelector: List<String>? = null, withCredentials: Boolean? = null, timeout: Duration? = null, scrollBehavior: HxScrollBehaviour? = null, defaultFocusScroll: Boolean? = null, getCacheBusterParam: Boolean? = null, globalViewTransitions: Boolean? = null, methodsThatUseUrlParams: Collection<HttpVerb>? = null, selfRequestsOnly: Boolean? = null, ignoreTitle: Boolean? = null, scrollIntoViewOnBoost: Boolean? = null, triggerSpecsCache: String? = null, allowNestedOobSwaps: Boolean? = null, responseHandling: Collection<HtmxConfig.ResponseHandling>? = null)

Types

Link copied to clipboard
@Serializable
data class ResponseHandling(val code: String? = null, val swap: Boolean, val error: Boolean? = null, val ignoreTitle: Boolean? = null, val select: String? = null, val target: String? = null, val swapOverride: String? = null, val event: String? = null)

Properties

Link copied to clipboard
@SerialName(value = "addedClass")
val addedClass: String? = null

defaults to htmx-added

Link copied to clipboard
@SerialName(value = "allowEval")
val allowEval: Boolean? = null

defaults to true, can be used to disable htmx’s use of eval for certain features (e.g. trigger filters)

Link copied to clipboard
@SerialName(value = "allowNestedOobSwaps")
val allowNestedOobSwaps: Boolean? = null

defaults to true, whether to process OOB swaps on elements that are nested within the main response element. See Nested OOB Swaps.

Link copied to clipboard
@SerialName(value = "allowScriptTags")
val allowScriptTags: Boolean? = null

defaults to true, determines if htmx will process script tags found in new content

Link copied to clipboard
@SerialName(value = "attributesToSettle")
val attributesToSettle: Collection<String>? = null

defaults to "class", "style", "width", "height", the attributes to settle during the settling phase

Link copied to clipboard
@SerialName(value = "defaultFocusScroll")
val defaultFocusScroll: Boolean? = null

if the focused element should be scrolled into view, defaults to false and can be overridden using the focus-scroll swap modifier.

Link copied to clipboard
@Serializable(with = MillisecondsSerializer::class)
@SerialName(value = "defaultSettleDelay")
val defaultSettleDelay: Duration? = null

defaults to 20

Link copied to clipboard
@Serializable(with = MillisecondsSerializer::class)
@SerialName(value = "defaultSwapDelay")
val defaultSwapDelay: Duration? = null

defaults to 0

Link copied to clipboard
@SerialName(value = "defaultSwapStyle")
val defaultSwapStyle: HxSwap? = null

defaults to innerHTML

Link copied to clipboard
@SerialName(value = "disableSelector")
val disableSelector: List<String>? = null

defaults to hx-disable, data-hx-disable, htmx will not process elements with this attribute on it or a parent

Link copied to clipboard
@SerialName(value = "getCacheBusterParam")
val getCacheBusterParam: Boolean? = null

defaults to false, if set to true htmx will include a cache-busting parameter in GET requests to avoid caching partial responses by the browser

Link copied to clipboard
@SerialName(value = "globalViewTransitions")
val globalViewTransitions: Boolean? = null

if set to true, htmx will use the View Transition API when swapping in new content.

Link copied to clipboard
@SerialName(value = "historyCacheSize")
val historyCacheSize: Int? = null

defaults to 10

Link copied to clipboard
@SerialName(value = "historyEnabled")
val historyEnabled: Boolean? = null

defaults to true, really only useful for testing

Link copied to clipboard
@SerialName(value = "ignoreTitle")
val ignoreTitle: Boolean? = null

defaults to false, if set to true htmx will not update the title of the document when a title tag is found in new content

Link copied to clipboard
@SerialName(value = "includeIndicatorStyles")
val includeIndicatorStyles: Boolean? = null

defaults to true (determines if the indicator styles are loaded)

Link copied to clipboard
@SerialName(value = "indicatorClass")
val indicatorClass: String? = null

defaults to htmx-indicator

Link copied to clipboard
@SerialName(value = "inlineScriptNonce")
val inlineScriptNonce: String? = null

defaults to '', meaning that no nonce will be added to inline scripts

Link copied to clipboard
@SerialName(value = "methodsThatUseUrlParams")
val methodsThatUseUrlParams: Collection<HttpVerb>? = null

defaults to "get", htmx will format requests with these methods by encoding their parameters in the URL, not the request body

Link copied to clipboard
@SerialName(value = "refreshOnHistoryMiss")
val refreshOnHistoryMiss: Boolean? = null

defaults to false, if set to true htmx will issue a full page refresh on history misses rather than use an AJAX request

Link copied to clipboard
@SerialName(value = "requestClass")
val requestClass: String? = null

defaults to htmx-request

Link copied to clipboard
@SerialName(value = "responseHandling")
val responseHandling: Collection<HtmxConfig.ResponseHandling>? = null
Link copied to clipboard
@SerialName(value = "scrollBehavior")
val scrollBehavior: HxScrollBehaviour? = null

defaults to ‘smooth’, the behavior for a boosted link on page transitions. The allowed values are auto and smooth. Smooth will smoothscroll to the top of the page while auto will behave like a vanilla link.

Link copied to clipboard
@SerialName(value = "scrollIntoViewOnBoost")
val scrollIntoViewOnBoost: Boolean? = null

defaults to true, whether or not the target of a boosted element is scrolled into the viewport. If hx-target is omitted on a boosted element, the target defaults to body, causing the page to scroll to the top.

Link copied to clipboard
@SerialName(value = "selfRequestsOnly")
val selfRequestsOnly: Boolean? = null

defaults to false, if set to true will only allow AJAX requests to the same domain as the current document

Link copied to clipboard
@SerialName(value = "settlingClass")
val settlingClass: String? = null

defaults to htmx-settling

Link copied to clipboard
@SerialName(value = "swappingClass")
val swappingClass: String? = null

defaults to htmx-swapping

Link copied to clipboard
@Serializable(with = MillisecondsSerializer::class)
@SerialName(value = "timeout")
val timeout: Duration? = null

defaults to 0, the number of milliseconds a request can take before automatically being terminated

Link copied to clipboard
@SerialName(value = "triggerSpecsCache")
val triggerSpecsCache: String? = null

defaults to null, the cache to store evaluated trigger specifications into, improving parsing performance at the cost of more memory usage. You may define a simple object to use a never-clearing cache, or implement your own system using a proxy object

Link copied to clipboard
@SerialName(value = "withCredentials")
val withCredentials: Boolean? = null

defaults to false, allow cross-site Access-Control requests using credentials such as cookies, authorization headers or TLS client certificates

Link copied to clipboard
@SerialName(value = "wsBinaryType")
val wsBinaryType: WsBinaryType? = null

defaults to blob, the type of binary data being received over the WebSocket connection

Link copied to clipboard
@SerialName(value = "wsReconnectDelay")
val wsReconnectDelay: String? = null

defaults to full-jitter