Model Selector

Rich select for AI model selection with metadata display.

python 11 params

Preview

Opus 5Most capable200kPremium
Sonnet 5Balanced200kStandard
Haiku 4.5Fast and cost-effective200kFree
Arguments
model_selector(name='model', label='Model', options=[{'value': 'claude-opus-5', 'label': 'Opus 5', 'description': 'Most capable', 'context_window': '200k', 'tier': 'premium'}, {'value': 'claude-sonnet-5', 'label': 'Sonnet 5', 'description': 'Balanced', 'context_window': '200k', 'tier': 'standard'}, {'value': 'claude-haiku-4-5', 'label': 'Haiku 4.5', 'description': 'Fast and cost-effective', 'context_window': '200k', 'tier': 'free'}], value='claude-sonnet-5', event='select_model')

Usage

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


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

    def mount(self, request, **kwargs):
        self.component = ModelSelector(name='model', label='Model', options=[{'value': 'claude-opus-5', 'label': 'Opus 5', 'description': 'Most capable', 'context_window': '200k', 'tier': 'premium'}, {'value': 'claude-sonnet-5', 'label': 'Sonnet 5', 'description': 'Balanced', 'context_window': '200k', 'tier': 'standard'}, {'value': 'claude-haiku-4-5', 'label': 'Haiku 4.5', 'description': 'Fast and cost-effective', 'context_window': '200k', 'tier': 'free'}], value='claude-sonnet-5', event='select_model')

    @event_handler()
    def toggle_model_selector(self, **kwargs):
        self.component.is_open = not self.component.is_open

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

Events this component sends to the view: toggle_model_selector, select_model.

Parameters

NameTypeDefaultDescription
namestr'model'Form field name
optionslist | NoneNoneList of model option dicts (value, label, description, context_window, tier)
valuestr''Currently selected model value
eventstr — renames the event'select_model'djust event fired on selection
toggle_eventstr — renames the event'toggle_model_selector'djust event fired when the trigger is clicked. The host owns `is_open` — this component renders it, it does not track it.
is_openboolFalseWhether the option list is showing
placeholderstr'Select a model...'Placeholder text
disabledboolFalseWhether selector is disabled
labelstr''Optional label text
custom_classstr''Additional CSS classes
**kwargs— passed to `Component.__init__`: `id=` sets `component.id`, and any other keyword is kept as state——
Source & styles
FilePathNotes
moduledjust.components.components.model_selectorSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components-classes.cssDefines 16 of this component's classes at line 733, 735, 736, 737, 739, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752. Override those rules, or the custom properties they read, in a stylesheet loaded after it.