Component extensions

Simple extensions to standard HTML components, such as adding sensible defaults
from pprint import pprint

A

def A(
    *c, hx_get:NoneType=None, target_id:NoneType=None, hx_swap:NoneType=None, href:str='#', hx_vals:NoneType=None,
    hx_target:NoneType=None, id:NoneType=None, cls:NoneType=None, title:NoneType=None, style:NoneType=None,
    accesskey:NoneType=None, contenteditable:NoneType=None, dir:NoneType=None, draggable:NoneType=None,
    enterkeyhint:NoneType=None, hidden:NoneType=None, inert:NoneType=None, inputmode:NoneType=None,
    lang:NoneType=None, popover:NoneType=None, spellcheck:NoneType=None, tabindex:NoneType=None,
    translate:NoneType=None, hx_post:NoneType=None, hx_put:NoneType=None, hx_delete:NoneType=None,
    hx_patch:NoneType=None, hx_trigger:NoneType=None, hx_swap_oob:NoneType=None, hx_include:NoneType=None,
    hx_select:NoneType=None, hx_select_oob:NoneType=None, hx_indicator:NoneType=None, hx_push_url:NoneType=None,
    hx_confirm:NoneType=None, hx_disable:NoneType=None, hx_replace_url:NoneType=None, hx_disabled_elt:NoneType=None,
    hx_ext:NoneType=None, hx_headers:NoneType=None, hx_history:NoneType=None, hx_history_elt:NoneType=None,
    hx_inherit:NoneType=None, hx_params:NoneType=None, hx_preserve:NoneType=None, hx_prompt:NoneType=None,
    hx_request:NoneType=None, hx_sync:NoneType=None, hx_validate:NoneType=None, hx_action:NoneType=None,
    hx_method:NoneType=None, hx_config:NoneType=None, hx_ignore:NoneType=None, hx_on_blur:NoneType=None,
    hx_on_change:NoneType=None, hx_on_contextmenu:NoneType=None, hx_on_focus:NoneType=None,
    hx_on_input:NoneType=None, hx_on_invalid:NoneType=None, hx_on_reset:NoneType=None, hx_on_select:NoneType=None,
    hx_on_submit:NoneType=None, hx_on_keydown:NoneType=None, hx_on_keypress:NoneType=None, hx_on_keyup:NoneType=None,
    hx_on_click:NoneType=None, hx_on_dblclick:NoneType=None, hx_on_mousedown:NoneType=None,
    hx_on_mouseenter:NoneType=None, hx_on_mouseleave:NoneType=None, hx_on_mousemove:NoneType=None,
    hx_on_mouseout:NoneType=None, hx_on_mouseover:NoneType=None, hx_on_mouseup:NoneType=None,
    hx_on_wheel:NoneType=None, hx_on__abort:NoneType=None, hx_on__after_on_load:NoneType=None,
    hx_on__after_process_node:NoneType=None, hx_on__after_request:NoneType=None, hx_on__after_settle:NoneType=None,
    hx_on__after_swap:NoneType=None, hx_on__before_cleanup_element:NoneType=None,
    hx_on__before_on_load:NoneType=None, hx_on__before_process_node:NoneType=None,
    hx_on__before_request:NoneType=None, hx_on__before_swap:NoneType=None, hx_on__before_send:NoneType=None,
    hx_on__before_transition:NoneType=None, hx_on__config_request:NoneType=None, hx_on__confirm:NoneType=None,
    hx_on__history_cache_error:NoneType=None, hx_on__history_cache_miss:NoneType=None,
    hx_on__history_cache_miss_error:NoneType=None, hx_on__history_cache_miss_load:NoneType=None,
    hx_on__history_restore:NoneType=None, hx_on__before_history_save:NoneType=None, hx_on__load:NoneType=None,
    hx_on__no_sse_source_error:NoneType=None, hx_on__on_load_error:NoneType=None,
    hx_on__oob_after_swap:NoneType=None, hx_on__oob_before_swap:NoneType=None,
    hx_on__oob_error_no_target:NoneType=None, hx_on__prompt:NoneType=None, hx_on__pushed_into_history:NoneType=None,
    hx_on__replaced_in_history:NoneType=None, hx_on__response_error:NoneType=None, hx_on__send_abort:NoneType=None,
    hx_on__send_error:NoneType=None, hx_on__sse_error:NoneType=None, hx_on__sse_open:NoneType=None,
    hx_on__swap_error:NoneType=None, hx_on__target_error:NoneType=None, hx_on__timeout:NoneType=None,
    hx_on__validation_validate:NoneType=None, hx_on__validation_failed:NoneType=None,
    hx_on__validation_halted:NoneType=None, hx_on__xhr_abort:NoneType=None, hx_on__xhr_loadend:NoneType=None,
    hx_on__xhr_loadstart:NoneType=None, hx_on__xhr_progress:NoneType=None, hx_on__after_init:NoneType=None,
    hx_on__before_cleanup:NoneType=None, hx_on__before_history_update:NoneType=None,
    hx_on__before_init:NoneType=None, hx_on__before_process:NoneType=None,
    hx_on__before_history_restore:NoneType=None, hx_on__after_history_push:NoneType=None,
    hx_on__after_history_replace:NoneType=None, hx_on__error:NoneType=None, **kwargs
)->fastcore.xml.FT:

An A tag; href defaults to ‘#’ for more concise use with HTMX

A('text', ht_get='/get', target_id='id')

AX

def AX(
    txt, hx_get:NoneType=None, target_id:NoneType=None, hx_swap:NoneType=None, href:str='#', *,
    hx_vals:NoneType=None, hx_target:NoneType=None, id:NoneType=None, cls:NoneType=None, title:NoneType=None,
    style:NoneType=None, accesskey:NoneType=None, contenteditable:NoneType=None, dir:NoneType=None,
    draggable:NoneType=None, enterkeyhint:NoneType=None, hidden:NoneType=None, inert:NoneType=None,
    inputmode:NoneType=None, lang:NoneType=None, popover:NoneType=None, spellcheck:NoneType=None,
    tabindex:NoneType=None, translate:NoneType=None, hx_post:NoneType=None, hx_put:NoneType=None,
    hx_delete:NoneType=None, hx_patch:NoneType=None, hx_trigger:NoneType=None, hx_swap_oob:NoneType=None,
    hx_include:NoneType=None, hx_select:NoneType=None, hx_select_oob:NoneType=None, hx_indicator:NoneType=None,
    hx_push_url:NoneType=None, hx_confirm:NoneType=None, hx_disable:NoneType=None, hx_replace_url:NoneType=None,
    hx_disabled_elt:NoneType=None, hx_ext:NoneType=None, hx_headers:NoneType=None, hx_history:NoneType=None,
    hx_history_elt:NoneType=None, hx_inherit:NoneType=None, hx_params:NoneType=None, hx_preserve:NoneType=None,
    hx_prompt:NoneType=None, hx_request:NoneType=None, hx_sync:NoneType=None, hx_validate:NoneType=None,
    hx_action:NoneType=None, hx_method:NoneType=None, hx_config:NoneType=None, hx_ignore:NoneType=None,
    hx_on_blur:NoneType=None, hx_on_change:NoneType=None, hx_on_contextmenu:NoneType=None, hx_on_focus:NoneType=None,
    hx_on_input:NoneType=None, hx_on_invalid:NoneType=None, hx_on_reset:NoneType=None, hx_on_select:NoneType=None,
    hx_on_submit:NoneType=None, hx_on_keydown:NoneType=None, hx_on_keypress:NoneType=None, hx_on_keyup:NoneType=None,
    hx_on_click:NoneType=None, hx_on_dblclick:NoneType=None, hx_on_mousedown:NoneType=None,
    hx_on_mouseenter:NoneType=None, hx_on_mouseleave:NoneType=None, hx_on_mousemove:NoneType=None,
    hx_on_mouseout:NoneType=None, hx_on_mouseover:NoneType=None, hx_on_mouseup:NoneType=None,
    hx_on_wheel:NoneType=None, hx_on__abort:NoneType=None, hx_on__after_on_load:NoneType=None,
    hx_on__after_process_node:NoneType=None, hx_on__after_request:NoneType=None, hx_on__after_settle:NoneType=None,
    hx_on__after_swap:NoneType=None, hx_on__before_cleanup_element:NoneType=None,
    hx_on__before_on_load:NoneType=None, hx_on__before_process_node:NoneType=None,
    hx_on__before_request:NoneType=None, hx_on__before_swap:NoneType=None, hx_on__before_send:NoneType=None,
    hx_on__before_transition:NoneType=None, hx_on__config_request:NoneType=None, hx_on__confirm:NoneType=None,
    hx_on__history_cache_error:NoneType=None, hx_on__history_cache_miss:NoneType=None,
    hx_on__history_cache_miss_error:NoneType=None, hx_on__history_cache_miss_load:NoneType=None,
    hx_on__history_restore:NoneType=None, hx_on__before_history_save:NoneType=None, hx_on__load:NoneType=None,
    hx_on__no_sse_source_error:NoneType=None, hx_on__on_load_error:NoneType=None,
    hx_on__oob_after_swap:NoneType=None, hx_on__oob_before_swap:NoneType=None,
    hx_on__oob_error_no_target:NoneType=None, hx_on__prompt:NoneType=None, hx_on__pushed_into_history:NoneType=None,
    hx_on__replaced_in_history:NoneType=None, hx_on__response_error:NoneType=None, hx_on__send_abort:NoneType=None,
    hx_on__send_error:NoneType=None, hx_on__sse_error:NoneType=None, hx_on__sse_open:NoneType=None,
    hx_on__swap_error:NoneType=None, hx_on__target_error:NoneType=None, hx_on__timeout:NoneType=None,
    hx_on__validation_validate:NoneType=None, hx_on__validation_failed:NoneType=None,
    hx_on__validation_halted:NoneType=None, hx_on__xhr_abort:NoneType=None, hx_on__xhr_loadend:NoneType=None,
    hx_on__xhr_loadstart:NoneType=None, hx_on__xhr_progress:NoneType=None, hx_on__after_init:NoneType=None,
    hx_on__before_cleanup:NoneType=None, hx_on__before_history_update:NoneType=None,
    hx_on__before_init:NoneType=None, hx_on__before_process:NoneType=None,
    hx_on__before_history_restore:NoneType=None, hx_on__after_history_push:NoneType=None,
    hx_on__after_history_replace:NoneType=None, hx_on__error:NoneType=None, **kwargs
)->fastcore.xml.FT:

An A tag with just one text child, allowing hx_get, target_id, and hx_swap to be positional params

AX('text', '/get', 'id')

Forms


Form

def Form(
    *c, enctype:str='multipart/form-data', target_id:NoneType=None, hx_vals:NoneType=None, hx_target:NoneType=None,
    id:NoneType=None, cls:NoneType=None, title:NoneType=None, style:NoneType=None, accesskey:NoneType=None,
    contenteditable:NoneType=None, dir:NoneType=None, draggable:NoneType=None, enterkeyhint:NoneType=None,
    hidden:NoneType=None, inert:NoneType=None, inputmode:NoneType=None, lang:NoneType=None, popover:NoneType=None,
    spellcheck:NoneType=None, tabindex:NoneType=None, translate:NoneType=None, hx_get:NoneType=None,
    hx_post:NoneType=None, hx_put:NoneType=None, hx_delete:NoneType=None, hx_patch:NoneType=None,
    hx_trigger:NoneType=None, hx_swap:NoneType=None, hx_swap_oob:NoneType=None, hx_include:NoneType=None,
    hx_select:NoneType=None, hx_select_oob:NoneType=None, hx_indicator:NoneType=None, hx_push_url:NoneType=None,
    hx_confirm:NoneType=None, hx_disable:NoneType=None, hx_replace_url:NoneType=None, hx_disabled_elt:NoneType=None,
    hx_ext:NoneType=None, hx_headers:NoneType=None, hx_history:NoneType=None, hx_history_elt:NoneType=None,
    hx_inherit:NoneType=None, hx_params:NoneType=None, hx_preserve:NoneType=None, hx_prompt:NoneType=None,
    hx_request:NoneType=None, hx_sync:NoneType=None, hx_validate:NoneType=None, hx_action:NoneType=None,
    hx_method:NoneType=None, hx_config:NoneType=None, hx_ignore:NoneType=None, hx_on_blur:NoneType=None,
    hx_on_change:NoneType=None, hx_on_contextmenu:NoneType=None, hx_on_focus:NoneType=None,
    hx_on_input:NoneType=None, hx_on_invalid:NoneType=None, hx_on_reset:NoneType=None, hx_on_select:NoneType=None,
    hx_on_submit:NoneType=None, hx_on_keydown:NoneType=None, hx_on_keypress:NoneType=None, hx_on_keyup:NoneType=None,
    hx_on_click:NoneType=None, hx_on_dblclick:NoneType=None, hx_on_mousedown:NoneType=None,
    hx_on_mouseenter:NoneType=None, hx_on_mouseleave:NoneType=None, hx_on_mousemove:NoneType=None,
    hx_on_mouseout:NoneType=None, hx_on_mouseover:NoneType=None, hx_on_mouseup:NoneType=None,
    hx_on_wheel:NoneType=None, hx_on__abort:NoneType=None, hx_on__after_on_load:NoneType=None,
    hx_on__after_process_node:NoneType=None, hx_on__after_request:NoneType=None, hx_on__after_settle:NoneType=None,
    hx_on__after_swap:NoneType=None, hx_on__before_cleanup_element:NoneType=None,
    hx_on__before_on_load:NoneType=None, hx_on__before_process_node:NoneType=None,
    hx_on__before_request:NoneType=None, hx_on__before_swap:NoneType=None, hx_on__before_send:NoneType=None,
    hx_on__before_transition:NoneType=None, hx_on__config_request:NoneType=None, hx_on__confirm:NoneType=None,
    hx_on__history_cache_error:NoneType=None, hx_on__history_cache_miss:NoneType=None,
    hx_on__history_cache_miss_error:NoneType=None, hx_on__history_cache_miss_load:NoneType=None,
    hx_on__history_restore:NoneType=None, hx_on__before_history_save:NoneType=None, hx_on__load:NoneType=None,
    hx_on__no_sse_source_error:NoneType=None, hx_on__on_load_error:NoneType=None,
    hx_on__oob_after_swap:NoneType=None, hx_on__oob_before_swap:NoneType=None,
    hx_on__oob_error_no_target:NoneType=None, hx_on__prompt:NoneType=None, hx_on__pushed_into_history:NoneType=None,
    hx_on__replaced_in_history:NoneType=None, hx_on__response_error:NoneType=None, hx_on__send_abort:NoneType=None,
    hx_on__send_error:NoneType=None, hx_on__sse_error:NoneType=None, hx_on__sse_open:NoneType=None,
    hx_on__swap_error:NoneType=None, hx_on__target_error:NoneType=None, hx_on__timeout:NoneType=None,
    hx_on__validation_validate:NoneType=None, hx_on__validation_failed:NoneType=None,
    hx_on__validation_halted:NoneType=None, hx_on__xhr_abort:NoneType=None, hx_on__xhr_loadend:NoneType=None,
    hx_on__xhr_loadstart:NoneType=None, hx_on__xhr_progress:NoneType=None, hx_on__after_init:NoneType=None,
    hx_on__before_cleanup:NoneType=None, hx_on__before_history_update:NoneType=None,
    hx_on__before_init:NoneType=None, hx_on__before_process:NoneType=None,
    hx_on__before_history_restore:NoneType=None, hx_on__after_history_push:NoneType=None,
    hx_on__after_history_replace:NoneType=None, hx_on__error:NoneType=None, **kwargs
)->fastcore.xml.FT:

A Form tag; identical to plain ft_hx version except default enctype='multipart/form-data'


Hidden

def Hidden(
    value:Any='', id:Any=None, *, target_id:NoneType=None, hx_vals:NoneType=None, hx_target:NoneType=None,
    cls:NoneType=None, title:NoneType=None, style:NoneType=None, accesskey:NoneType=None,
    contenteditable:NoneType=None, dir:NoneType=None, draggable:NoneType=None, enterkeyhint:NoneType=None,
    hidden:NoneType=None, inert:NoneType=None, inputmode:NoneType=None, lang:NoneType=None, popover:NoneType=None,
    spellcheck:NoneType=None, tabindex:NoneType=None, translate:NoneType=None, hx_get:NoneType=None,
    hx_post:NoneType=None, hx_put:NoneType=None, hx_delete:NoneType=None, hx_patch:NoneType=None,
    hx_trigger:NoneType=None, hx_swap:NoneType=None, hx_swap_oob:NoneType=None, hx_include:NoneType=None,
    hx_select:NoneType=None, hx_select_oob:NoneType=None, hx_indicator:NoneType=None, hx_push_url:NoneType=None,
    hx_confirm:NoneType=None, hx_disable:NoneType=None, hx_replace_url:NoneType=None, hx_disabled_elt:NoneType=None,
    hx_ext:NoneType=None, hx_headers:NoneType=None, hx_history:NoneType=None, hx_history_elt:NoneType=None,
    hx_inherit:NoneType=None, hx_params:NoneType=None, hx_preserve:NoneType=None, hx_prompt:NoneType=None,
    hx_request:NoneType=None, hx_sync:NoneType=None, hx_validate:NoneType=None, hx_action:NoneType=None,
    hx_method:NoneType=None, hx_config:NoneType=None, hx_ignore:NoneType=None, hx_on_blur:NoneType=None,
    hx_on_change:NoneType=None, hx_on_contextmenu:NoneType=None, hx_on_focus:NoneType=None,
    hx_on_input:NoneType=None, hx_on_invalid:NoneType=None, hx_on_reset:NoneType=None, hx_on_select:NoneType=None,
    hx_on_submit:NoneType=None, hx_on_keydown:NoneType=None, hx_on_keypress:NoneType=None, hx_on_keyup:NoneType=None,
    hx_on_click:NoneType=None, hx_on_dblclick:NoneType=None, hx_on_mousedown:NoneType=None,
    hx_on_mouseenter:NoneType=None, hx_on_mouseleave:NoneType=None, hx_on_mousemove:NoneType=None,
    hx_on_mouseout:NoneType=None, hx_on_mouseover:NoneType=None, hx_on_mouseup:NoneType=None,
    hx_on_wheel:NoneType=None, hx_on__abort:NoneType=None, hx_on__after_on_load:NoneType=None,
    hx_on__after_process_node:NoneType=None, hx_on__after_request:NoneType=None, hx_on__after_settle:NoneType=None,
    hx_on__after_swap:NoneType=None, hx_on__before_cleanup_element:NoneType=None,
    hx_on__before_on_load:NoneType=None, hx_on__before_process_node:NoneType=None,
    hx_on__before_request:NoneType=None, hx_on__before_swap:NoneType=None, hx_on__before_send:NoneType=None,
    hx_on__before_transition:NoneType=None, hx_on__config_request:NoneType=None, hx_on__confirm:NoneType=None,
    hx_on__history_cache_error:NoneType=None, hx_on__history_cache_miss:NoneType=None,
    hx_on__history_cache_miss_error:NoneType=None, hx_on__history_cache_miss_load:NoneType=None,
    hx_on__history_restore:NoneType=None, hx_on__before_history_save:NoneType=None, hx_on__load:NoneType=None,
    hx_on__no_sse_source_error:NoneType=None, hx_on__on_load_error:NoneType=None,
    hx_on__oob_after_swap:NoneType=None, hx_on__oob_before_swap:NoneType=None,
    hx_on__oob_error_no_target:NoneType=None, hx_on__prompt:NoneType=None, hx_on__pushed_into_history:NoneType=None,
    hx_on__replaced_in_history:NoneType=None, hx_on__response_error:NoneType=None, hx_on__send_abort:NoneType=None,
    hx_on__send_error:NoneType=None, hx_on__sse_error:NoneType=None, hx_on__sse_open:NoneType=None,
    hx_on__swap_error:NoneType=None, hx_on__target_error:NoneType=None, hx_on__timeout:NoneType=None,
    hx_on__validation_validate:NoneType=None, hx_on__validation_failed:NoneType=None,
    hx_on__validation_halted:NoneType=None, hx_on__xhr_abort:NoneType=None, hx_on__xhr_loadend:NoneType=None,
    hx_on__xhr_loadstart:NoneType=None, hx_on__xhr_progress:NoneType=None, hx_on__after_init:NoneType=None,
    hx_on__before_cleanup:NoneType=None, hx_on__before_history_update:NoneType=None,
    hx_on__before_init:NoneType=None, hx_on__before_process:NoneType=None,
    hx_on__before_history_restore:NoneType=None, hx_on__after_history_push:NoneType=None,
    hx_on__after_history_replace:NoneType=None, hx_on__error:NoneType=None, **kwargs
)->fastcore.xml.FT:

An Input of type ‘hidden’


CheckboxX

def CheckboxX(
    checked:bool=False, label:NoneType=None, value:str='1', id:NoneType=None, name:NoneType=None, *,
    target_id:NoneType=None, hx_vals:NoneType=None, hx_target:NoneType=None, cls:NoneType=None, title:NoneType=None,
    style:NoneType=None, accesskey:NoneType=None, contenteditable:NoneType=None, dir:NoneType=None,
    draggable:NoneType=None, enterkeyhint:NoneType=None, hidden:NoneType=None, inert:NoneType=None,
    inputmode:NoneType=None, lang:NoneType=None, popover:NoneType=None, spellcheck:NoneType=None,
    tabindex:NoneType=None, translate:NoneType=None, hx_get:NoneType=None, hx_post:NoneType=None,
    hx_put:NoneType=None, hx_delete:NoneType=None, hx_patch:NoneType=None, hx_trigger:NoneType=None,
    hx_swap:NoneType=None, hx_swap_oob:NoneType=None, hx_include:NoneType=None, hx_select:NoneType=None,
    hx_select_oob:NoneType=None, hx_indicator:NoneType=None, hx_push_url:NoneType=None, hx_confirm:NoneType=None,
    hx_disable:NoneType=None, hx_replace_url:NoneType=None, hx_disabled_elt:NoneType=None, hx_ext:NoneType=None,
    hx_headers:NoneType=None, hx_history:NoneType=None, hx_history_elt:NoneType=None, hx_inherit:NoneType=None,
    hx_params:NoneType=None, hx_preserve:NoneType=None, hx_prompt:NoneType=None, hx_request:NoneType=None,
    hx_sync:NoneType=None, hx_validate:NoneType=None, hx_action:NoneType=None, hx_method:NoneType=None,
    hx_config:NoneType=None, hx_ignore:NoneType=None, hx_on_blur:NoneType=None, hx_on_change:NoneType=None,
    hx_on_contextmenu:NoneType=None, hx_on_focus:NoneType=None, hx_on_input:NoneType=None,
    hx_on_invalid:NoneType=None, hx_on_reset:NoneType=None, hx_on_select:NoneType=None, hx_on_submit:NoneType=None,
    hx_on_keydown:NoneType=None, hx_on_keypress:NoneType=None, hx_on_keyup:NoneType=None, hx_on_click:NoneType=None,
    hx_on_dblclick:NoneType=None, hx_on_mousedown:NoneType=None, hx_on_mouseenter:NoneType=None,
    hx_on_mouseleave:NoneType=None, hx_on_mousemove:NoneType=None, hx_on_mouseout:NoneType=None,
    hx_on_mouseover:NoneType=None, hx_on_mouseup:NoneType=None, hx_on_wheel:NoneType=None,
    hx_on__abort:NoneType=None, hx_on__after_on_load:NoneType=None, hx_on__after_process_node:NoneType=None,
    hx_on__after_request:NoneType=None, hx_on__after_settle:NoneType=None, hx_on__after_swap:NoneType=None,
    hx_on__before_cleanup_element:NoneType=None, hx_on__before_on_load:NoneType=None,
    hx_on__before_process_node:NoneType=None, hx_on__before_request:NoneType=None, hx_on__before_swap:NoneType=None,
    hx_on__before_send:NoneType=None, hx_on__before_transition:NoneType=None, hx_on__config_request:NoneType=None,
    hx_on__confirm:NoneType=None, hx_on__history_cache_error:NoneType=None, hx_on__history_cache_miss:NoneType=None,
    hx_on__history_cache_miss_error:NoneType=None, hx_on__history_cache_miss_load:NoneType=None,
    hx_on__history_restore:NoneType=None, hx_on__before_history_save:NoneType=None, hx_on__load:NoneType=None,
    hx_on__no_sse_source_error:NoneType=None, hx_on__on_load_error:NoneType=None,
    hx_on__oob_after_swap:NoneType=None, hx_on__oob_before_swap:NoneType=None,
    hx_on__oob_error_no_target:NoneType=None, hx_on__prompt:NoneType=None, hx_on__pushed_into_history:NoneType=None,
    hx_on__replaced_in_history:NoneType=None, hx_on__response_error:NoneType=None, hx_on__send_abort:NoneType=None,
    hx_on__send_error:NoneType=None, hx_on__sse_error:NoneType=None, hx_on__sse_open:NoneType=None,
    hx_on__swap_error:NoneType=None, hx_on__target_error:NoneType=None, hx_on__timeout:NoneType=None,
    hx_on__validation_validate:NoneType=None, hx_on__validation_failed:NoneType=None,
    hx_on__validation_halted:NoneType=None, hx_on__xhr_abort:NoneType=None, hx_on__xhr_loadend:NoneType=None,
    hx_on__xhr_loadstart:NoneType=None, hx_on__xhr_progress:NoneType=None, hx_on__after_init:NoneType=None,
    hx_on__before_cleanup:NoneType=None, hx_on__before_history_update:NoneType=None,
    hx_on__before_init:NoneType=None, hx_on__before_process:NoneType=None,
    hx_on__before_history_restore:NoneType=None, hx_on__after_history_push:NoneType=None,
    hx_on__after_history_replace:NoneType=None, hx_on__error:NoneType=None, **kwargs
)->fastcore.xml.FT:

A Checkbox optionally inside a Label, preceded by a Hidden with matching name

show(CheckboxX(True, 'Check me out!'))

Script

def Script(
    code:str='', *, id:NoneType=None, cls:NoneType=None, title:NoneType=None, style:NoneType=None,
    attrmap:NoneType=None, valmap:NoneType=None, ft_cls:NoneType=None, **kwargs
)->fastcore.xml.FT:

A Script tag that doesn’t escape its code


Style

def Style(
    *c, id:NoneType=None, cls:NoneType=None, title:NoneType=None, style:NoneType=None, attrmap:NoneType=None,
    valmap:NoneType=None, ft_cls:NoneType=None, **kwargs
)->fastcore.xml.FT:

A Style tag that doesn’t escape its code

Style and script templates


double_braces

def double_braces(
    s
):

Convert single braces to double braces if next to special chars or newline


undouble_braces

def undouble_braces(
    s
):

Convert double braces to single braces if next to special chars or newline


loose_format

def loose_format(
    s, **kw
):

String format s using kw, without being strict about braces outside of template params


ScriptX

def ScriptX(
    fname, src:NoneType=None, nomodule:NoneType=None, type:NoneType=None, _async:NoneType=None, defer:NoneType=None,
    charset:NoneType=None, crossorigin:NoneType=None, integrity:NoneType=None, **kw
):

A script element with contents read from fname


replace_css_vars

def replace_css_vars(
    css, pre:str='tpl', **kwargs
):

Replace var(--) CSS variables with kwargs if name prefix matches pre


StyleX

def StyleX(
    fname, **kw
):

A style element with contents read from fname and variables replaced from kw


Nbsp

def Nbsp():

A non-breaking space

Surreal and JS


Surreal

def Surreal(
    code:str
):

Wrap code in domReadyExecute and set m=me() and p=me('-')


On

def On(
    code:str, event:str='click', sel:str='', me:bool=True
):

An async surreal.js script block event handler for event on selector sel,p, making available parent p, event ev, and target e


Prev

def Prev(
    code:str, event:str='click'
):

An async surreal.js script block event handler for event on previous sibling, with same vars as On


Now

def Now(
    code:str, sel:str=''
):

An async surreal.js script block on selector me(sel)


AnyNow

def AnyNow(
    sel:str, code:str
):

An async surreal.js script block on selector any(sel)


run_js

def run_js(
    js, id:NoneType=None, **kw
):

Run js script, auto-generating id based on name of caller if needed, and js-escaping any kw params


HtmxOn

def HtmxOn(
    eventname:str, code:str
):

Run code on htmx event eventname; both the v2 (htmx:camelCase) and v4 (htmx-dash-case) spellings are bound, and only the loaded version’s fires


jsd

def jsd(
    org, repo, root, path, prov:str='gh', typ:str='script', ver:NoneType=None, esm:bool=False, **kwargs
)->fastcore.xml.FT:

jsdelivr Script or CSS Link tag, or URL

Other helpers


Fragment

def Fragment(
    *c
):

An empty tag, used as a container

fts = Fragment(P('1st'), P('2nd'))
print(to_xml(fts))
  <p>1st</p>
  <p>2nd</p>

Titled

def Titled(
    title:str='FastHTML app', *args, cls:str='container', target_id:NoneType=None, hx_vals:NoneType=None,
    hx_target:NoneType=None, id:NoneType=None, style:NoneType=None, accesskey:NoneType=None,
    contenteditable:NoneType=None, dir:NoneType=None, draggable:NoneType=None, enterkeyhint:NoneType=None,
    hidden:NoneType=None, inert:NoneType=None, inputmode:NoneType=None, lang:NoneType=None, popover:NoneType=None,
    spellcheck:NoneType=None, tabindex:NoneType=None, translate:NoneType=None, hx_get:NoneType=None,
    hx_post:NoneType=None, hx_put:NoneType=None, hx_delete:NoneType=None, hx_patch:NoneType=None,
    hx_trigger:NoneType=None, hx_swap:NoneType=None, hx_swap_oob:NoneType=None, hx_include:NoneType=None,
    hx_select:NoneType=None, hx_select_oob:NoneType=None, hx_indicator:NoneType=None, hx_push_url:NoneType=None,
    hx_confirm:NoneType=None, hx_disable:NoneType=None, hx_replace_url:NoneType=None, hx_disabled_elt:NoneType=None,
    hx_ext:NoneType=None, hx_headers:NoneType=None, hx_history:NoneType=None, hx_history_elt:NoneType=None,
    hx_inherit:NoneType=None, hx_params:NoneType=None, hx_preserve:NoneType=None, hx_prompt:NoneType=None,
    hx_request:NoneType=None, hx_sync:NoneType=None, hx_validate:NoneType=None, hx_action:NoneType=None,
    hx_method:NoneType=None, hx_config:NoneType=None, hx_ignore:NoneType=None, hx_on_blur:NoneType=None,
    hx_on_change:NoneType=None, hx_on_contextmenu:NoneType=None, hx_on_focus:NoneType=None,
    hx_on_input:NoneType=None, hx_on_invalid:NoneType=None, hx_on_reset:NoneType=None, hx_on_select:NoneType=None,
    hx_on_submit:NoneType=None, hx_on_keydown:NoneType=None, hx_on_keypress:NoneType=None, hx_on_keyup:NoneType=None,
    hx_on_click:NoneType=None, hx_on_dblclick:NoneType=None, hx_on_mousedown:NoneType=None,
    hx_on_mouseenter:NoneType=None, hx_on_mouseleave:NoneType=None, hx_on_mousemove:NoneType=None,
    hx_on_mouseout:NoneType=None, hx_on_mouseover:NoneType=None, hx_on_mouseup:NoneType=None,
    hx_on_wheel:NoneType=None, hx_on__abort:NoneType=None, hx_on__after_on_load:NoneType=None,
    hx_on__after_process_node:NoneType=None, hx_on__after_request:NoneType=None, hx_on__after_settle:NoneType=None,
    hx_on__after_swap:NoneType=None, hx_on__before_cleanup_element:NoneType=None,
    hx_on__before_on_load:NoneType=None, hx_on__before_process_node:NoneType=None,
    hx_on__before_request:NoneType=None, hx_on__before_swap:NoneType=None, hx_on__before_send:NoneType=None,
    hx_on__before_transition:NoneType=None, hx_on__config_request:NoneType=None, hx_on__confirm:NoneType=None,
    hx_on__history_cache_error:NoneType=None, hx_on__history_cache_miss:NoneType=None,
    hx_on__history_cache_miss_error:NoneType=None, hx_on__history_cache_miss_load:NoneType=None,
    hx_on__history_restore:NoneType=None, hx_on__before_history_save:NoneType=None, hx_on__load:NoneType=None,
    hx_on__no_sse_source_error:NoneType=None, hx_on__on_load_error:NoneType=None,
    hx_on__oob_after_swap:NoneType=None, hx_on__oob_before_swap:NoneType=None,
    hx_on__oob_error_no_target:NoneType=None, hx_on__prompt:NoneType=None, hx_on__pushed_into_history:NoneType=None,
    hx_on__replaced_in_history:NoneType=None, hx_on__response_error:NoneType=None, hx_on__send_abort:NoneType=None,
    hx_on__send_error:NoneType=None, hx_on__sse_error:NoneType=None, hx_on__sse_open:NoneType=None,
    hx_on__swap_error:NoneType=None, hx_on__target_error:NoneType=None, hx_on__timeout:NoneType=None,
    hx_on__validation_validate:NoneType=None, hx_on__validation_failed:NoneType=None,
    hx_on__validation_halted:NoneType=None, hx_on__xhr_abort:NoneType=None, hx_on__xhr_loadend:NoneType=None,
    hx_on__xhr_loadstart:NoneType=None, hx_on__xhr_progress:NoneType=None, hx_on__after_init:NoneType=None,
    hx_on__before_cleanup:NoneType=None, hx_on__before_history_update:NoneType=None,
    hx_on__before_init:NoneType=None, hx_on__before_process:NoneType=None,
    hx_on__before_history_restore:NoneType=None, hx_on__after_history_push:NoneType=None,
    hx_on__after_history_replace:NoneType=None, hx_on__error:NoneType=None, **kwargs
)->fastcore.xml.FT:

An HTML partial containing a Title, and H1, and any provided children

show(Titled('my page', P('para')))
my page

my page

para


Socials

def Socials(
    title, site_name, description, image, url:NoneType=None, w:int=1200, h:int=630, twitter_site:NoneType=None,
    creator:NoneType=None, card:str='summary'
):

OG and Twitter social card headers


YouTubeEmbed

def YouTubeEmbed(
    video_id:str, *, width:int=560, height:int=315, start_time:int=0, no_controls:bool=False,
    title:str='YouTube video player', cls:str='', **kwargs
):

Embed a YouTube video


Favicon

def Favicon(
    light_icon, dark_icon
):

Light and dark favicon headers


clear

def clear(
    id
):

with_sid

def with_sid(
    app, dest, path:str='/'
):

LdJson

def LdJson(
    typ, data:dict, script:bool=False, extra:NoneType=None, **kwargs
)->fastcore.xml.FT:

A script tag containing JSON-LD structured data


LdContactPoint

def LdContactPoint(
    contact_type:str, email:str=None, phone:str=None, script:bool=False, **extra
)->dict:

Create a ContactPoint for JSON-LD


LdOrg

def LdOrg(
    name:str, url:str=None, logo:str=None, alt_name:str=None, same_as:list=None, contact_points:list=None,
    script:bool=False, **extra
)->dict:

JSON-LD Organization structured data

LdOrg(
    name="AnswerDotAI, Inc.", alt_name="SolveIt", 
    url="https://solve.it.com/", logo="https://solve.it.com/brand/logo.png",
    same_as=["https://www.fast.ai/", "https://twitter.com/fastdotai"],
    contact_points=[LdContactPoint("customer support", email="[email protected]")],
    script=True)

LdWebsite

def LdWebsite(
    name:str, url:str, script:bool=False, **extra
)->dict:

Create JSON-LD WebSite structured data


LdCourseInstance

def LdCourseInstance(
    course_mode:str='Online', start_date:str=None, end_date:str=None, location:dict=None, instructor:dict=None,
    script:bool=False, **extra
)->dict:

Create a CourseInstance for JSON-LD


LdCourse

def LdCourse(
    name:str, description:str, provider:dict, course_instance:dict=None, script:bool=False, **extra
)->dict:

Create JSON-LD Course structured data

LdCourse(
    name="How to Solve It With Code",
    description="A 5-week course teaching the SolveIt method...",
    provider={"@type": "Organization", "name": "FastDotAI", "sameAs": "https://fast.ai/"},
    course_instance=LdCourseInstance(
        start_date="2025-11-03", 
        end_date="2025-12-10",
        location={"@type": "VirtualLocation", "url": "https://solve.it.com/"},
        instructor={"@type": "Person", "name": "Jeremy Howard", "sameAs": "https://www.fast.ai/about/#jeremy"}
    ), script=True)

robots_txt

def robots_txt(
    app, allow_all:bool=True, disallow_paths:NoneType=None, sitemap_url:NoneType=None, crawl_delay:NoneType=None
):

Add a /robots.txt route to the app

Parameters: - allow_all=True - Allow all crawling (default) - disallow_paths - List of paths to disallow (e.g. ["/admin", "/private"]) - sitemap_url - URL to your sitemap.xml - crawl_delay - Seconds between requests for polite crawlers

Usage examples:

app = FastHTML()
# Allow everything
robots_txt(app)

# Block specific paths with sitemap
robots_txt(app, disallow_paths=["/admin", "/api"], sitemap_url="https://mysite.com/sitemap.xml")

# Block everything
robots_txt(app, allow_all=False)

sitemap_xml

def sitemap_xml(
    app, urls, loc_base:str=''
):

Add a /sitemap.xml route to the app with list of URLs


sitemap_url

def sitemap_url(
    url_info, loc_base:str=''
):

Create a sitemap URL element from url_info (string or dict)

# Simple URLs
sitemap_xml(app, ["/", "/about", "/contact"], loc_base="https://mysite.com")

# With metadata
sitemap_xml(app, [
    {"loc": "/", "changefreq": "daily", "priority": 1.0},
    {"loc": "/about", "changefreq": "monthly", "priority": 0.8},
    "/contact"  # Can mix simple strings with dicts
], loc_base="https://mysite.com")

upload_pb_attrs

def upload_pb_attrs(
    id:str='uploadprog'
):

Form hx_on progress attr that reveals and updates a hidden upload_pb of matching id

File uploads can take a while for large files, so it’s nice to show users a progress bar. With a progress bar like Progress(id='uploadprog', value='0', max='100', cls='hidden'), upload_pb_attrs returns an htmx event handler that reveals and updates it.

Add both to a form, along with htmx’s multipart encoding:

Form(Input(type='file', name='f'),
    Progress(id='uploadprog', value='0', max='100', cls='hidden'),
    Button('Upload'),
    hx_post='/upload', hx_encoding='multipart/form-data', **upload_pb_attrs())

As the browser uploads, htmx fires htmx:xhr:progress events carrying loaded and total byte counts. The handler waits for the first event that reports a total, then removes the hidden class and sets the bar’s value to the percentage uploaded.