Loading Overlay

Loading overlay component.

python 6 params

Preview

active

This card stays visible underneath the overlay.

python
loading_overlay(content='<p style="margin:0 0 0.5rem">This card stays visible underneath the overlay.</p><button type="button" dj-click="toggle_loading">Toggle the overlay</button>', text='Loading…')

Usage

views.py
python
from djust import LiveView
from djust.decorators import event_handler
from djust.components import LoadingOverlay
from django.utils.safestring import mark_safe


class MyView(LiveView):
    template_name = "my_template.html"

    def mount(self, request, **kwargs):
        self.component = LoadingOverlay(content=mark_safe('<p style="margin:0 0 0.5rem">This card stays visible underneath the overlay.</p><button type="button" dj-click="toggle_loading">Toggle the overlay</button>'), text='Loading…')

    @event_handler()
    def toggle_loading(self, **kwargs):
        self.component.active = not self.component.active
my_template.html
django
{{ component }}

Parameters

NameTypeDefault
contentstr''
activeboolFalse
textstr''
spinner_sizestr'md'
custom_classstr''
**kwargs— passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state
Source & styles
FilePathNotes
moduledjust.components.components.loading_overlaySubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 5 of this component's classes at line 1098, 1099, 1100, 1102, 1104. Override those rules, or the custom properties they read, in a stylesheet loaded after it.