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

Events this component sends to the view: send.

Needs a client hook djust does not ship: dj-hook="MentionsInput". The markup renders, but the interaction described above is yours to add — register window.djust.hooks.MentionsInput = { mounted() { … } } before client.js loads (see the hooks guide).

Parameters

NameTypeDefault
namestr'message'
usersList[dict] | NoneNone
eventstr — renames the event'send'
placeholderstr'Type @ to mention...'
disabledboolFalse
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.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 789, 791, 792, 793, 794, 796, 797. 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 1718, 1720, 1723, 1724, 1726, 1728, 1729. Override those rules, or the custom properties they read, in a stylesheet loaded after it.