Combobox
Searchable select (combobox) component.
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 = valuemy_template.html
django
{{ component }}Events this component sends to the view: language_search, set_language.
Parameters
| Name | Type | Default |
|---|---|---|
| name | str | '' |
| label | str | '' |
| value | str | '' |
| options | list | None | None |
| event | str — renames the event | '' |
| search_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.combobox | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 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. |
| css | djust_theming/scaffold.css | Defines 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. |
| css | djust_theming/components.css | Defines 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. |