Loading Overlay
Loading overlay component.
Preview
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.activemy_template.html
django
{{ component }}Parameters
| Name | Type | Default |
|---|---|---|
| content | str | '' |
| active | bool | False |
| text | str | '' |
| spinner_size | str | 'md' |
| custom_class | str | '' |
| **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
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.loading_overlay | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 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. |