Dependent Select
Cascading dropdown that reloads options when a parent field changes.
Preview
Usage
views.py
python
from djust import LiveView
from djust.components import DependentSelect
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = DependentSelect()my_template.html
django
{{ component }}Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| name | str | '' | Form field name. |
| parent | str | '' | Name of the parent field this select depends on. |
| source_event | str — renames the event | '' | djust event to fire when parent changes. |
| label | str | '' | Optional label text. |
| placeholder | str | 'Select...' | Placeholder text when nothing selected. |
| value | str | '' | Currently selected value. |
| options | list | None | None | List of dicts with 'value'/'label' keys, or list of strings. |
| loading | bool | False | Show spinner while loading options. |
| disabled | bool | False | Whether the select is disabled. |
| required | bool | False | Whether the field is required. |
| error | str | '' | Error message to display. |
| custom_class | str | '' | Additional CSS classes. |
| **kwargs | — passed to `Component.__init__`: `id=` sets `component.id`, and any other keyword is kept as state | — | — |
Source & styles
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.dependent_select | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 2 of this component's classes at line 1440, 1441. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |