Multi Select
Multi-select checkbox list component.
Preview
Arguments
multi_select(name='frameworks', label='Frameworks', options=[{'value': 'django', 'label': 'Django'}, {'value': 'flask', 'label': 'Flask'}, {'value': 'fastapi', 'label': 'FastAPI'}], selected=['django'], event='set_frameworks')Usage
views.py
python
from djust import LiveView
from djust.decorators import event_handler
from djust.components import MultiSelect
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = MultiSelect(name='frameworks', label='Frameworks', options=[{'value': 'django', 'label': 'Django'}, {'value': 'flask', 'label': 'Flask'}, {'value': 'fastapi', 'label': 'FastAPI'}], selected=['django'], event='set_frameworks')
@event_handler()
def set_frameworks(self, value, **kwargs):
self.component.selected = ... # the handler gets `option` (the box) and `value` (ticked or not)my_template.html
django
{{ component }}Events this component sends to the view: set_frameworks.
Parameters
| Name | Type | Default |
|---|---|---|
| name | str | '' |
| label | str | '' |
| options | list | None | None |
| selected | list | None | None |
| event | str — renames the event | '' |
| placeholder | str | 'Search...' |
| custom_class | str | '' |
| **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.multi_select | 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 502, 934, 939, 941, 942. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |
| css | djust_theming/components.css | Defines 1 of this component's classes at line 1378. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |
| css | djust_theming/scaffold.css | Defines 1 of this component's classes at line 444. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |