Combobox

Searchable select (combobox) component.

python 9 params

Preview

Python
Rust
Go
Arguments
combobox(name='language', event='set_language', label='Language', value='python', options=[{'value': 'python', 'label': 'Python'}, {'value': 'rust', 'label': 'Rust'}, {'value': 'go', 'label': 'Go'}])

Usage

views.py
python
from djust import LiveView
from djust.decorators import event_handler
from djust.components import Combobox


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

    def mount(self, request, **kwargs):
        self.component = Combobox(name='language', event='set_language', label='Language', value='python', options=[{'value': 'python', 'label': 'Python'}, {'value': 'rust', 'label': 'Rust'}, {'value': 'go', 'label': 'Go'}])

    @event_handler()
    def language_search(self, **kwargs):
        pass  # your app acts on 'language_search'; no component state moves

    @event_handler()
    def set_language(self, value, **kwargs):
        self.component.value = value
my_template.html
django
{{ component }}

Events this component sends to the view: language_search, set_language.

Parameters

NameTypeDefaultDescription
namestr''form field name
labelstr''label text
valuestr''currently selected value
optionslist | NoneNonelist of dicts with keys: value, label
eventstr — renames the event''dj-change event name
search_eventstr — renames the event''dj-input event for search
placeholderstr'Search...'search input placeholder
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.comboboxSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 7 of this component's classes at line 481, 523, 525, 779, 780, 781, 783. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_theming/scaffold.cssDefines 3 of this component's classes at line 418, 438, 445. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_theming/components.cssDefines 2 of this component's classes at line 1114, 1453. Override those rules, or the custom properties they read, in a stylesheet loaded after it.