Collab Selection
Highlights text or cell ranges selected by other users.
Preview
selected textAda Lovelaceanother selectionGrace Hopper
Arguments
collab_selection(users=[{'name': 'Ada Lovelace', 'color': '#3b82f6', 'start': 10, 'end': 25, 'text': 'selected text'}, {'name': 'Grace Hopper', 'color': '#ef4444', 'start': 40, 'end': 55, 'text': 'another selection'}])Draws other users' selections over your content through a client hook djust does not ship — see below.
Usage
views.py
python
from djust import LiveView
from djust.components import CollabSelection
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = CollabSelection(users=[{'name': 'Ada Lovelace', 'color': '#3b82f6', 'start': 10, 'end': 25, 'text': 'selected text'}, {'name': 'Grace Hopper', 'color': '#ef4444', 'start': 40, 'end': 55, 'text': 'another selection'}])my_template.html
django
{{ component }}Needs its script on the page: <script src="{% static 'djust_components/collab-selection.js' %}"></script>. djust ships it; without it the markup renders but does not update in the browser.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| users | List[Union[dict, object]] | None | None | List of user dicts with name, color, and selection data. |
| custom_class | str | '' | Additional CSS classes. |
| target | str | '' | CSS selector of the element whose text the offsets index (optional). |
| **kwargs | — passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state | — | — |
Source & styles
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.collab_selection | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 4 of this component's classes at line 2314, 2315, 2316, 2317. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |