Multi Select

Multi-select checkbox list component.

python 8 params

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

NameTypeDefault
namestr''
labelstr''
optionslist | NoneNone
selectedlist | NoneNone
eventstr — renames the event''
placeholderstr'Search...'
custom_classstr''
**kwargs— passed to `Component.__init__`: `id=` sets `component.id`, and any other keyword is kept as state
Source & styles
FilePathNotes
moduledjust.components.components.multi_selectSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 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.
cssdjust_theming/components.cssDefines 1 of this component's classes at line 1378. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_theming/scaffold.cssDefines 1 of this component's classes at line 444. Override those rules, or the custom properties they read, in a stylesheet loaded after it.