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):
        ...  # write to self.component; the re-render carries it

    @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

NameTypeDefault
namestr''
labelstr''
valuestr''
optionslist | NoneNone
eventstr — renames the event''
search_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.comboboxSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 7 of this component's classes at line 458, 500, 502, 753, 754, 755, 757. 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, 437, 444. 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 1045, 1378. Override those rules, or the custom properties they read, in a stylesheet loaded after it.