Tag Input

Tag input component for adding/removing tags.

python 7 params

Preview

djangorust
Arguments
tag_input(name='labels', label='Labels', event='add_tag', tags=['django', 'rust'])

Usage

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


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

    def mount(self, request, **kwargs):
        self.component = TagInput(name='labels', label='Labels', event='add_tag', tags=['django', 'rust'])

    @event_handler()
    def add_tag(self, **kwargs):
        self.component.tags = ...  # `add_tag` — see this component's docs
my_template.html
django
{{ component }}

Events this component sends to the view: add_tag.

Parameters

NameTypeDefaultDescription
namestr''form field name
tagslist | NoneNonelist of current tag strings
eventstr — renames the event''dj-click event name
placeholderstr'Add tag...'input placeholder
labelstr''label text
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.tag_inputSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 6 of this component's classes at line 525, 988, 989, 990, 991, 993. 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 1453. 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 445. Override those rules, or the custom properties they read, in a stylesheet loaded after it.