Skip to main content
Ctrl+K
FSharp.ViewEngine · DesignFSharp.ViewEngine · Key FeaturesFSharp.ViewEngine · Quick ExampleFSharp.ViewEngine · Getting StartedCore installation · Using .NET CLICore installation · Using Paket CLICore installation · Runtime SupportCore installation · Source DebuggingCore installation · Next StepsBuild your first view · Create the viewBuild your first view · Render the viewBuild your first view · Reuse componentsBuild your first view · NextElements and attributes · ElementsElements and attributes · AttributesElements and attributes · Mixed contentElements and attributes · Generic escape hatchesComposition and control flow · Functions as componentsComposition and control flow · Conditional contentComposition and control flow · SequencesRendering · FragmentsRendering · DocumentsRendering · Application boundariesEncoding and trusted content · Encoded by defaultEncoding and trusted content · Trusted raw contentEncoding and trusted content · Trusted names and expressionsAccessibility · Prefer native HTMLAccessibility · Names and relationshipsAccessibility · ARIA coverageAccessibility · Test behaviorCustom Elements & Attributes · Trusted Content BoundariesCustom Elements & Attributes · Custom ElementsCustom Elements & Attributes · elCustom Elements & Attributes · elVoidCustom Elements & Attributes · Nested Web ComponentsCustom Elements & Attributes · Custom AttributesCustom Elements & Attributes · _attrCustom Elements & Attributes · Key-value attributeCustom Elements & Attributes · Boolean attributeCustom Elements & Attributes · Combining with Built-in AttributesCustom Elements & Attributes · Extending the Html TypeCustom Elements & Attributes · Adding Custom ElementsCustom Elements & Attributes · Adding Custom AttributesCustom Elements & Attributes · Design System ExampleCustom Elements & Attributes · Shoelace ExampleSVG · Support PolicySVG · SetupSVG · Element ReferenceSVG · Numeric and Length ValuesSVG · Icon ExampleSVG · Chart and Text ExampleSVG · Gradients, Clipping, Masking, and ReuseSVG · AccessibilitySVG · Linking and NamespacesSVG · Attribute ReferenceSVG · Unsupported SVGDatastar · SetupDatastar · Core AttributesDatastar · data-signalsDatastar · data-bindDatastar · data-computedDatastar · data-effectDatastar · data-showDatastar · data-textDatastar · data-attrDatastar · data-classDatastar · data-styleDatastar · data-initDatastar · data-onDatastar · data-on-intersectDatastar · data-on-intervalDatastar · data-on-signal-patchDatastar · data-on-signal-patch-filterDatastar · data-indicatorDatastar · data-refDatastar · data-json-signalsDatastar · data-ignoreDatastar · data-ignore-morphDatastar · data-preserve-attrDatastar · Pro AttributesDatastar · data-animateDatastar · data-custom-validityDatastar · data-match-mediaDatastar · data-on-rafDatastar · data-on-resizeDatastar · data-persistDatastar · data-query-stringDatastar · data-replace-urlDatastar · data-scroll-into-viewDatastar · data-view-transitionDatastar · Trusted ExpressionsDatastar · Content Security PolicyDatastar · Complete ExampleHTMX · SetupHTMX · Request MethodsHTMX · hx-getHTMX · hx-postHTMX · hx-putHTMX · hx-patchHTMX · hx-deleteHTMX · Request Data and ConfigurationHTMX · hx-encodingHTMX · hx-headersHTMX · hx-includeHTMX · hx-paramsHTMX · hx-requestHTMX · hx-valsHTMX · Targeting and SwappingHTMX · hx-targetHTMX · hx-selectHTMX · hx-select-oobHTMX · hx-swapHTMX · hx-swap-oobHTMX · hx-preserveHTMX · Requests in FlightHTMX · hx-indicatorHTMX · hx-disabled-eltHTMX · hx-syncHTMX · hx-validateHTMX · Triggering and InteractionHTMX · hx-triggerHTMX · hx-confirmHTMX · hx-promptHTMX · hx-onHTMX · Navigation and HistoryHTMX · hx-boostHTMX · hx-push-urlHTMX · hx-replace-urlHTMX · hx-historyHTMX · hx-history-eltHTMX · Inheritance and ProcessingHTMX · hx-disableHTMX · hx-disinheritHTMX · hx-inheritHTMX · hx-extHTMX · Generic and Deprecated AttributesHTMX · Complete ExampleAlpine.js · SetupAlpine.js · Core DirectivesAlpine.js · x-dataAlpine.js · x-initAlpine.js · x-showAlpine.js · x-bindAlpine.js · x-onAlpine.js · x-textAlpine.js · x-htmlAlpine.js · x-modelAlpine.js · x-modelableAlpine.js · x-forAlpine.js · x-transitionAlpine.js · x-effectAlpine.js · x-ignoreAlpine.js · x-refAlpine.js · x-cloakAlpine.js · x-teleportAlpine.js · x-ifAlpine.js · x-idAlpine.js · Plugin DirectivesAlpine.js · x-maskAlpine.js · x-intersectAlpine.js · x-resizeAlpine.js · x-collapseAlpine.js · x-trapAlpine.js · x-anchorAlpine.js · x-sortAlpine.js · Plugins Without Directive HelpersAlpine.js · Trusted ExpressionsAlpine.js · Complete ExampleTailwind Plus Elements · SetupTailwind Plus Elements · Shared AttributesTailwind Plus Elements · AutocompleteTailwind Plus Elements · Command PaletteTailwind Plus Elements · Copy ButtonTailwind Plus Elements · DialogTailwind Plus Elements · DisclosureTailwind Plus Elements · Dropdown MenuTailwind Plus Elements · PopoverTailwind Plus Elements · SelectTailwind Plus Elements · TabsTailwind Plus Elements · Runtime ReadinessComponents · Get startedComponents · ActionsComponents · FeedbackComponents · Data displayComponents · Form controlsComponents · NavigationComponents · OverlaysComponents · LayoutComponents · Code and diagramsComponent installation · Install the CLIComponent installation · Add componentsComponent installation · Install the build toolsComponent installation · Configure TailwindComponent installation · Import component JavaScriptComponent installation · Build and watchComponent installation · Serve and use the componentsComponent installation · Update installed componentsButton · InstallationButton · UsageButton · SizesButton · ColorsButton · VariantsButton · Uniform paddingButton · All color variantsButton · PendingButton · ChildrenButton · Icon-only variantsButton · Custom paletteButton · Primary buttonsButton · Secondary buttonsButton · Ghost buttonsButton · Native Ghost resetButton · Destructive buttonsButton · Destructive pendingButton · Disabled buttonsButton · Primary icon-onlyButton · Pending icon-onlyButton · Disabled icon-onlyButton · Datastar visibilityButton · Row actionsButton · Labels and focusButton · API referenceLink · InstallationLink · UsageLink · Text underlineLink · Inherited presentationLink · SizesLink · Uniform paddingLink · ColorsLink · VariantsLink · All color variantsLink · Icon-only variantsLink · Icon-only sizesLink · Native new-tab navigationLink · API referenceButton group · InstallationButton group · UsageButton group · Grouped actionsButton group · Native link segmentsButton group · Label and Select segmentsButton group · Custom controls and popup isolationButton group · Vertical orientationButton group · API referenceDropdown menu · InstallationDropdown menu · UsageDropdown menu · IconsDropdown menu · Keyboard hintsDropdown menu · CheckboxesDropdown menu · Radio choicesDropdown menu · Disabled itemsDropdown menu · Destructive actionDropdown menu · Outlined page actionDropdown menu · Custom native controlDropdown menu · Full context row and supporting descriptionsDropdown menu · Grouped states and refreshDropdown menu · Row actionsDropdown menu · API referenceToggle button · InstallationToggle button · UsageToggle button · PendingToggle button · DisabledToggle button · Content, sizes and variantsToggle button · API referenceToggle group · InstallationToggle group · UsageToggle group · Single selectionToggle group · Connected multiple and single-item groupsToggle group · Multiple, spaced and unavailableToggle group · SubmissionToggle group · Vertical orientationToggle group · API referenceBadge · InstallationBadge · UsageBadge · ColorsBadge · VariantsBadge · API referenceNotice · InstallationNotice · UsageNotice · ColorsNotice · VariantsNotice · Success with downloadNotice · WarningNotice · Error with recovery linkNotice · Announce an updateNotice · API referenceNotification · InstallationNotification · UsageNotification · Persistent with an actionNotification · Custom lifetimeNotification · AnnouncementsNotification · API referenceLoading indicator · InstallationLoading indicator · UsageLoading indicator · With visible labelLoading indicator · API referenceProgress · InstallationProgress · UsageProgress · IndeterminateProgress · CompleteProgress · FailedProgress · API referenceEmpty state · InstallationEmpty state · UsageEmpty state · Title onlyEmpty state · With recovery actionEmpty state · API referenceSkeleton · InstallationSkeleton · UsageSkeleton · TextSkeleton · Avatar rowSkeleton · CardSkeleton · Explicit dimensionsSkeleton · API referenceCallout · InstallationCallout · UsageCallout · API referenceIcon · InstallationIcon · UsageIcon · Heroicons familiesIcon · Brand logosIcon · Rendered-size overridesIcon · API referenceTable · InstallationTable · UsageTable · Comfortable rowsTable · Hover highlightingTable · With status valuesTable · With checkboxesTable · Scrollable rows and sticky headingsTable · Stacked on mobileTable · Sortable recordsTable · Hierarchical itemsTable · Row actionsTable · Empty stateTable · Infinite scrollTable · API referenceChart · InstallationChart · UsageChart · ColumnChart · Horizontal barChart · SankeyChart · Updating options and handling eventsChart · Empty dataChart · API referenceDescription list · InstallationDescription list · UsageDescription list · Three-column detailsDescription list · Four-column detailsDescription list · With supporting textDescription list · API referenceMetric · InstallationMetric · UsageMetric · With trend and statusMetric · With review statusMetric · Multiple metricsMetric · API referenceAvatar · InstallationAvatar · UsageAvatar · Fallbacks and sizesAvatar · ImageAvatar · Image unavailableAvatar · DecorativeAvatar · API referenceCopy and reveal · InstallationCopy and reveal · UsageCopy and reveal · Icon actionsCopy and reveal · Initially revealedCopy and reveal · API referenceDay calendar · InstallationDay calendar · UsageDay calendar · Overlapping sessionsDay calendar · Compact controlsDay calendar · Provisional time selectionDay calendar · API referenceWeek calendar · InstallationWeek calendar · UsageWeek calendar · Events and date navigationWeek calendar · Shared controls and event detailsWeek calendar · API referenceMonth calendar · InstallationMonth calendar · UsageMonth calendar · Events and date navigationMonth calendar · Compact monthMonth calendar · Single-date selectionMonth calendar · Clearable single dateMonth calendar · Current dateMonth calendar · Today shortcutMonth calendar · Date rangeMonth calendar · Bounds, unavailable dates and Monday startMonth calendar · Month and year selectorsMonth calendar · Busy availabilityMonth calendar · Read-only selectionMonth calendar · API referenceYear calendar · InstallationYear calendar · UsageYear calendar · Event indicators and date navigationYear calendar · API referenceKbd · InstallationKbd · UsageKbd · Shortcut groupKbd · API referenceSeparator · InstallationSeparator · UsageSeparator · Orientation and semanticsSeparator · API referenceCard · InstallationCard · UsageCard · Header and footerCard · With mediaCard · API referenceMessage · InstallationMessage · UsageMessage · Sender and receiverMessage · Metadata and actions without an avatarMessage · API referenceInput · InstallationInput · UsageInput · Consistent control sizesInput · With help textInput · RequiredInput · OptionalInput · Validation errorInput · Native searchInput · DisabledInput · Read-onlyInput · API referenceInput group · InstallationInput group · UsageInput group · IconInput group · SuffixInput group · Text addonsInput group · Icon and keyboard hintInput group · Addon popup keeps its own controlsInput group · Textarea header and footerInput group · Validation errorInput group · Checking with visible feedbackInput group · API referenceField · InstallationField · UsageField · Custom controlField · Responsive label and control rowsField · Semantic fieldsetField · Labels and focusField · API referenceTextarea · InstallationTextarea · UsageTextarea · Visually hidden labelTextarea · With instructionsTextarea · Validation errorTextarea · Read-onlyTextarea · DisabledTextarea · API referenceFile selection · InstallationFile selection · UsageFile selection · Multiple filesFile selection · ValidationFile selection · DisabledFile selection · API referenceTag input · InstallationTag input · UsageTag input · SubmissionTag input · ValidationTag input · PendingTag input · DisabledTag input · API referenceError summary · InstallationError summary · UsageError summary · API referenceSelect · InstallationSelect · UsageSelect · Custom items and groupsSelect · Multiple selectionSelect · Local searchSelect · Remote searchSelect · Form validationSelect · DisabledSelect · PendingSelect · API referenceTime picker · InstallationTime picker · UsageTime picker · 24-hour display and boundsTime picker · Disabled and read-onlyTime picker · API referenceDate picker · InstallationDate picker · UsageDate picker · Clearable single dateDate picker · Current dateDate picker · Today shortcutDate picker · Date rangeDate picker · Month and year selectorsDate picker · Bounds and unavailable datesDate picker · ValidationDate picker · PendingDate picker · DisabledDate picker · Read-onlyDate picker · API referenceCheckbox · InstallationCheckbox · UsageCheckbox · With help textCheckbox · IndeterminateCheckbox · Required confirmation with validationCheckbox · CheckedCheckbox · PendingCheckbox · DisabledCheckbox · API referenceSwitch · InstallationSwitch · UsageSwitch · With help textSwitch · Setting with submissionSwitch · PendingSwitch · DisabledSwitch · Validation errorSwitch · SizesSwitch · Stacked layoutSwitch · API referenceRadio group · InstallationRadio group · UsageRadio group · Option descriptionsRadio group · Horizontal orientationRadio group · Required choice with validationRadio group · PendingRadio group · DisabledRadio group · API referenceChoice cards · InstallationChoice cards · UsageChoice cards · Single choiceChoice cards · Multiple choicesChoice cards · ValidationChoice cards · API referenceField group · InstallationField group · UsageField group · Without descriptionField group · Disabled fieldsetField group · Horizontal fieldsField group · Responsive fieldsField group · API referenceBreadcrumbs · InstallationBreadcrumbs · UsageBreadcrumbs · Middle overflowBreadcrumbs · Available spaceBreadcrumbs · API referenceSide nav · InstallationSide nav · UsageSide nav · Sections and collapsible groupsSide nav · Header, context, content and footerSide nav · Nested navigation with badges and actionsSide nav · Expansion and scrollSide nav · API referenceTabs · InstallationTabs · UsageTabs · Server-owned selectionTabs · Underlined tabs with refreshTabs · Vertical, icons and disabled itemsTabs · API referencePagination · InstallationPagination · UsagePagination · Page navigationPagination · Numbers onlyPagination · Previous and next onlyPagination · API referenceCommand · InstallationCommand · UsageCommand · Groups, icons and shortcutsCommand · Contextual page linksCommand · Actions and disabled itemsCommand · Dialog paletteCommand · Empty resultsCommand · API referenceBottom navigation · InstallationBottom navigation · UsageBottom navigation · Four destinationsBottom navigation · Three destinationsBottom navigation · API referenceDialog · InstallationDialog · UsageDialog · Modal dialogDialog · Server-validated confirmationDialog · App-contained dialogDialog · Labels and focusDialog · API referenceDrawer · InstallationDrawer · UsageDrawer · NavigationDrawer · Standard detail drawerDrawer · Wide editing formDrawer · Start-side filtersDrawer · Top and bottom edgesDrawer · App-contained drawerDrawer · Labels and focusDrawer · API referenceFloating panel · InstallationFloating panel · UsageFloating panel · Minimized with restoreFloating panel · ChecklistFloating panel · API referencePopover · InstallationPopover · UsagePopover · With formPopover · Side and alignmentPopover · Custom native triggerPopover · API referenceTooltip · InstallationTooltip · UsageTooltip · Existing descriptionTooltip · Bottom placementTooltip · API referenceBrowser · InstallationBrowser · UsageBrowser · With an address barBrowser · Review controls and expansionBrowser · API referencePhone · InstallationPhone · UsagePhone · With screen contentPhone · Review controls and expansionPhone · API referenceResizable · InstallationResizable · UsageResizable · Horizontal split panelsResizable · Vertical split panelsResizable · API referenceSlide · InstallationSlide · UsageSlide · CoverSlide · API referencePresentation · InstallationPresentation · UsagePresentation · API referencePage header · InstallationPage header · UsagePage header · Title and page actionsPage header · API referenceSection header · InstallationSection header · UsageSection header · Description, actions and dividerSection header · API referenceSection · InstallationSection · UsageSection · Section spacingSection · API referenceDisclosure · InstallationDisclosure · UsageDisclosure · API referencePage top bar · InstallationPage top bar · UsagePage top bar · Full-width shell barPage top bar · API referenceCode block · InstallationCode block · Quick start with GiraffeCode block · Add syntax highlightingCode block · Optional Prism stylesheetCode block · F#Code block · PythonCode block · TypeScriptCode block · BashCode block · SQLCode block · Optional nonce CSPCode block · API referenceExample · InstallationExample · UsageExample · API referenceMermaid · InstallationMermaid · UsageMermaid · Sequence constructorsMermaid · API referenceF# API reference · InstallationF# API reference · UsageF# API reference · API referenceStandalone F# scripts · PrerequisitesStandalone F# scripts · Use the Core packageStandalone F# scripts · Install editable components into a scriptStandalone F# scripts · Compose the HTML pageStandalone F# scripts · Build and viewStandalone F# scripts · Keep source ownership explicitStandalone F# scripts · Next stepsGiraffe integration · Minimal ExampleGiraffe integration · How It WorksGiraffe integration · Title ElementsUsing signals · Bind a value and handle an actionUsing signals · Related examplesTheming · Apply a theme to a regionTheming · Override only what you needTheming · Scope CSS variables to a regionTheming · CSS-variable referenceTheming · Internal variablesTheming · Add an appearance pickerTheming · Theme APIBuild a presentation · Create a deckBuild a presentation · Compose slides with ordinary F#Build a presentation · Build and openBuild a presentation · Present in the browserBuild a presentation · Print or save as PDFBuild a presentation · Explore the complete exampleBenchmarks · Rendering performanceBenchmarks · EnvironmentBenchmarks · ReproduceExamples · Templates

HTMX

FSharp.ViewEngine provides all non-deprecated HTMX 2.0.9 attributes through the Htmx type. See the official HTMX 2 reference for the complete value grammar and inheritance rules.

On this page

Setup

Open the Htmx type to access HTMX attributes:

open FSharp.ViewEngine
open type Html
open type Htmx

Request Methods

hx-get

Issue a GET request to a URL with _hxGet.

button {
    _hxGet "/api/items"
    "Load items"
}

hx-post

Issue a POST request to a URL with _hxPost.

form {
    _hxPost "/api/items"
    input { _name "title" }
    button { "Create item" }
}

hx-put

Issue a PUT request to a URL with _hxPut.

button {
    _hxPut "/api/items/1"
    "Replace item"
}

hx-patch

Issue a PATCH request to a URL with _hxPatch.

button {
    _hxPatch "/api/items/1"
    "Update item"
}

hx-delete

Issue a DELETE request to a URL with _hxDelete.

button {
    _hxDelete "/api/items/1"
    "Delete item"
}

Request Data and Configuration

hx-encoding

Change the request encoding with _hxEncoding, typically for file uploads.

form {
    _hxPost "/api/upload"
    _hxEncoding "multipart/form-data"
}

hx-headers

Add request headers as JSON with _hxHeaders.

button {
    _hxPost "/api/items"
    _hxHeaders """{"X-CSRF-Token": "token"}"""
    "Create item"
}

hx-include

Include values from additional elements with _hxInclude.

button {
    _hxPost "/api/search"
    _hxInclude "[name='query']"
    "Search"
}

hx-params

Filter submitted parameters with _hxParams. Values include *, none, a comma-separated list, or not followed by a list.

form {
    _hxPost "/api/profile"
    _hxParams "name,email"
}

hx-request

Configure request timeout, credentials, or headers with _hxRequest.

button {
    _hxGet "/api/report"
    _hxRequest """{"timeout": 5000}"""
    "Load report"
}

hx-vals

Add values to the request as JSON with _hxVals.

button {
    _hxPost "/api/action"
    _hxVals """{"source": "toolbar"}"""
    "Run action"
}

Targeting and Swapping

hx-target

Choose the element that receives the response with _hxTarget.

button {
    _hxGet "/api/items"
    _hxTarget "#results"
    "Load items"
}
div { _id "results" }

hx-select

Select a fragment from the response with _hxSelect.

button {
    _hxGet "/items/1"
    _hxSelect "#item-details"
    "Load details"
}

hx-select-oob

Select one or more response fragments for out-of-band swaps with _hxSelectOOB.

button {
    _hxGet "/dashboard"
    _hxSelectOOB "#alerts,#navigation:outerHTML"
    "Refresh dashboard"
}

hx-swap

Control how the response is swapped with _hxSwap. Swap modifiers can be included in the same value.

button {
    _hxGet "/api/items"
    _hxSwap "beforeend settle:200ms"
    "Append items"
}

hx-swap-oob

Mark response content for an out-of-band swap with _hxSwapOOB.

div {
    _id "notifications"
    _hxSwapOOB "true"
    "Updated notifications"
}

hx-preserve

Preserve an element by id across ancestor updates with the presence-only _hxPreserve attribute.

video {
    _id "tutorial"
    _hxPreserve
}

Requests in Flight

hx-indicator

Choose the element that receives the htmx-request class with _hxIndicator.

button {
    _hxGet "/api/report"
    _hxIndicator "#spinner"
    "Load report"
}
span { _id "spinner"; _class "htmx-indicator"; "Loading..." }

hx-disabled-elt

Disable selected elements while a request is in flight with _hxDisabledElt.

button {
    _hxPost "/api/items"
    _hxDisabledElt "this"
    "Create item"
}

hx-sync

Coordinate requests with _hxSync using a selector and synchronization strategy.

input {
    _name "query"
    _hxGet "/api/search"
    _hxTrigger "input changed delay:300ms"
    _hxSync "this:replace"
}

hx-validate

Force an element to run HTML validation before a request with _hxValidate.

input {
    _type "email"
    _hxPost "/api/validate-email"
    _hxValidate "true"
}

Triggering and Interaction

hx-trigger

Specify the events and modifiers that trigger a request with _hxTrigger.

input {
    _name "query"
    _hxGet "/api/search"
    _hxTrigger "keyup changed delay:500ms"
}

hx-confirm

Ask for confirmation before issuing a request with _hxConfirm.

button {
    _hxDelete "/account"
    _hxConfirm "Delete your account?"
    "Delete account"
}

hx-prompt

Prompt for a value before issuing a request with _hxPrompt. HTMX sends the result in the HX-Prompt header.

button {
    _hxDelete "/account"
    _hxPrompt "Enter your account name to confirm"
    "Delete account"
}

hx-on

Handle DOM or HTMX events with _hxOn. Attribute names are case-insensitive, so use kebab-case HTMX event names rather than camelCase.

form {
    _hxPost "/api/items"
    _hxOn ("htmx:before-request", "showSpinner()")
    _hxOn ("htmx:after-request", "hideSpinner()")
}

Security: _hxOn executes inline JavaScript. Only use trusted script content and follow your application's Content Security Policy.

hx-boost

Progressively enhance links and forms with _hxBoost.

main {
    _hxBoost "true"
    a { _href "/account"; "Account" }
}

hx-push-url

Push the fetched URL, a custom URL, or no URL into browser history with _hxPushUrl.

button {
    _hxGet "/account"
    _hxPushUrl "true"
    "Open account"
}

hx-replace-url

Replace the current browser-history URL with _hxReplaceUrl.

button {
    _hxGet "/account"
    _hxReplaceUrl "/account/home"
    "Open account"
}

hx-history

Prevent sensitive page state from entering the HTMX history cache with _hxHistory "false".

section {
    _hxHistory "false"
    "Sensitive account details"
}

hx-history-elt

Choose a narrower history snapshot element with the presence-only _hxHistoryElt attribute.

main {
    _id "content"
    _hxHistoryElt
}

Inheritance and Processing

hx-disable

Disable HTMX processing for an element and its descendants with the presence-only _hxDisable attribute.

section {
    _hxDisable
    "HTMX ignores this subtree"
}

hx-disinherit

Disable inheritance for selected attributes, or all attributes with *, using _hxDisinherit.

section {
    _hxDisinherit "hx-target hx-swap"
}

hx-inherit

Explicitly enable inheritance when HTMX's disableInheritance configuration is active with _hxInherit.

section {
    _hxTarget "#content"
    _hxInherit "hx-target"
}

hx-ext

Enable one or more HTMX extensions for an element and its descendants with _hxExt.

body {
    _hxExt "preload,morph"
}

Generic and Deprecated Attributes

Use _hx for extension attributes or newer HTMX attributes that do not yet have a dedicated helper:

div {
    _hx ("custom-extension-option", "value")
}

hx-vars is deprecated in HTMX 2; use _hxVals. The former hx-sse and hx-ws core attributes moved to extensions and therefore do not have dedicated core helpers.

Complete Example

A search form combining request, synchronization, targeting, indicator, and history attributes:

form {
    _hxGet "/api/search"
    _hxTrigger "input changed delay:300ms, search"
    _hxTarget "#search-results"
    _hxIndicator "#search-spinner"
    _hxDisabledElt "find button"
    _hxSync "this:replace"
    _hxPushUrl "true"

    input { _type "search"; _name "query"; _hxValidate "true" }
    button { _type "submit"; "Search" }
    span { _id "search-spinner"; _class "htmx-indicator"; "Searching..." }
    div { _id "search-results" }
}