Modals API Reference
Example Modal
Simple Test Modal
With some somewhat brief content to show that it works!
def ex_modal():
return Div(
Button("Open Modal",data_uk_toggle="target: #my-modal" ),
Modal(ModalTitle("Simple Test Modal"),
P("With some somewhat brief content to show that it works!", cls=TextPresets.muted_sm),
footer=ModalCloseButton("Close", cls=ButtonT.primary),id='my-modal'))
Modal
SourceModal(*c, header=None, footer=None, cls=(), dialog_cls=(), header_cls='p-6', body_cls='space-y-6', footer_cls=(), id='', open=False, **kwargs) -> fastcore.xml.FT Creates a modal with the appropriate classes to put the boilerplate in the appropriate places for you
cComponents to put in theModalBody(often forms, sign in buttons, images, etc.)headerComponents that go in theModalHeader(often aModalTitle)footerComponents that go in theModalFooter(often aModalCloseButton)clsAdditional classes on the outermostModalContainerdialog_clsAdditional classes on theModalDialogheader_clsAdditional classes on theModalHeaderbody_clsAdditional classes on theModalBodyfooter_clsAdditional classes on theModalFooteridid for the outermost containeropenWhether the modal is open (typically used for HTMX controlled modals)kwargs
Returns: Fully styled modal FT Component
ModalCloseButton
SourceModalCloseButton(*c, cls='absolute top-3 right-3', htmx=False, **kwargs) -> fastcore.xml.FT Creates a button that closes a modal with js
cComponents to put in the button (often text and/or an icon)clsAdditional classes on the buttonhtmxWhether to use HTMX to close the modal (must add hx_get to a route that closes the modal)kwargs
Returns: Button(..., cls='uk-modal-close') + hx_target and hx_swap if htmx is True
The remainder of the Modal functions below are used internally by the `Modal` function for you. You shouldn't need to use them unless you're doing something really special.
ModalTitle
SourceModalTitle(*c, cls=(), **kwargs) -> fastcore.xml.FT Creates a modal title
cComponents to put in theModalTitle(often text)clsAdditional classes on theModalTitlekwargs
Returns: H2(..., cls='uk-modal-title')
ModalFooter
SourceModalFooter(*c, cls=(), **kwargs) -> fastcore.xml.FT Creates a modal footer
cComponents to put in theModalFooter(often buttons)clsAdditional classes on theModalFooterkwargs
Returns: Div(..., cls='uk-modal-footer')
ModalBody
SourceModalBody(*c, cls=(), **kwargs) -> fastcore.xml.FT Creates a modal body
cComponents to put in theModalBody(often forms, sign in buttons, images, etc.)clsAdditional classes on theModalBodykwargs
Returns: Div(..., cls='uk-modal-body')
ModalHeader
SourceModalHeader(*c, cls=(), **kwargs) -> fastcore.xml.FT Creates a modal header
cComponents to put in theModalHeaderclsAdditional classes on theModalHeaderkwargs
Returns: Div(..., cls='uk-modal-header')
ModalDialog
SourceModalDialog(*c, cls=(), **kwargs) -> fastcore.xml.FT Creates a modal dialog
cComponents to put in theModalDialog(oftenModalBody,ModalHeader, etc)clsAdditional classes on theModalDialogkwargs
Returns: Div(..., cls='uk-modal-dialog')
ModalContainer
SourceModalContainer(*c, cls=(), **kwargs) -> fastcore.xml.FT Creates a modal container that components go in
cComponents to put in the modal (oftenModalDialog)clsAdditional classes on theModalContainerkwargs
Returns: Div(..., cls='uk-modal uk-modal-container')