Modals API Reference
Example Modal
This is a subtitle
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
c
Components to put in theModalBody
(often forms, sign in buttons, images, etc.)header
Components that go in theModalHeader
(often aModalTitle
)footer
Components that go in theModalFooter
(often aModalCloseButton
)cls
Additional classes on the outermostModalContainer
dialog_cls
Additional classes on theModalDialog
header_cls
Additional classes on theModalHeader
body_cls
Additional classes on theModalBody
footer_cls
Additional classes on theModalFooter
id
id for the outermost containeropen
Whether the modal is open (typically used for HTMX controlled modals)kwargs
Returns: Fully styled modal FT Component
ModalCloseButton
SourceModalCloseButton(*c, cls=(), htmx=False, **kwargs) -> fastcore.xml.FT
Creates a button that closes a modal with js
c
Components to put in the button (often text and/or an icon)cls
Additional classes on the buttonhtmx
Whether 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
c
Components to put in theModalTitle
(often text)cls
Additional classes on theModalTitle
kwargs
Returns: H2(..., cls='uk-modal-title')
ModalFooter
SourceModalFooter(*c, cls=(), **kwargs) -> fastcore.xml.FT
Creates a modal footer
c
Components to put in theModalFooter
(often buttons)cls
Additional classes on theModalFooter
kwargs
Returns: Div(..., cls='uk-modal-footer')
ModalBody
SourceModalBody(*c, cls=(), **kwargs) -> fastcore.xml.FT
Creates a modal body
c
Components to put in theModalBody
(often forms, sign in buttons, images, etc.)cls
Additional classes on theModalBody
kwargs
Returns: Div(..., cls='uk-modal-body')
ModalHeader
SourceModalHeader(*c, cls=(), **kwargs) -> fastcore.xml.FT
Creates a modal header
c
Components to put in theModalHeader
cls
Additional classes on theModalHeader
kwargs
Returns: Div(..., cls='uk-modal-header')
ModalDialog
SourceModalDialog(*c, cls=(), **kwargs) -> fastcore.xml.FT
Creates a modal dialog
c
Components to put in theModalDialog
(oftenModalBody
,ModalHeader
, etc)cls
Additional classes on theModalDialog
kwargs
Returns: Div(..., cls='uk-modal-dialog')
ModalContainer
SourceModalContainer(*c, cls=(), **kwargs) -> fastcore.xml.FT
Creates a modal container that components go in
c
Components to put in the modal (oftenModalDialog
)cls
Additional classes on theModalContainer
kwargs
Returns: Div(..., cls='uk-modal uk-modal-container')