Mentions Input

Text input that triggers a user mention dropdown on @ character.

python 7 params

Preview

  • ALAda Lovelace
  • GHGrace Hopper
Arguments
mentions_input(name='comment', users=[{'id': 'u1', 'name': 'Ada Lovelace'}, {'id': 'u2', 'name': 'Grace Hopper'}], placeholder='Mention someone…')

Usage

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


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

    def mount(self, request, **kwargs):
        self.component = MentionsInput(name='comment', users=[{'id': 'u1', 'name': 'Ada Lovelace'}, {'id': 'u2', 'name': 'Grace Hopper'}], placeholder='Mention someone…')

    @event_handler()
    def send(self, value=None, **kwargs):
        pass  # your app acts on 'send'; no component state moves
my_template.html
django
{{ component }}

Events this component sends to the view: send.

Needs its script on the page: <script src="{% static 'djust_components/mentions-input.js' %}"></script>. djust ships it; without it the markup renders but does not update in the browser.

Parameters

NameTypeDefaultDescription
namestr'message'Input field name attribute.
usersList[dict] | NoneNoneList of user dicts with id, name, and optional avatar.
eventstr — renames the event'send'Event name fired on submit (default: "send").
placeholderstr'Type @ to mention...'Placeholder text.
disabledboolFalseWhether the input is disabled.
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.mentions_inputSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components-classes.cssDefines 7 of this component's classes at line 791, 793, 794, 795, 796, 798, 799. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_components/components.cssDefines 7 of this component's classes at line 1744, 1746, 1749, 1750, 1753, 1755, 1756. Override those rules, or the custom properties they read, in a stylesheet loaded after it.