Overview
TheActiveCollaborators component shows circular avatars of all users currently present in a Liveblocks room. It provides real-time presence awareness, displaying who else is viewing or editing the document.
Props
This component takes no props. It automatically retrieves active collaborators from the Liveblocks room context using theuseOthers() hook.
Features
- Real-time presence: Automatically updates when users join or leave
- User avatars: Displays circular profile images for each active user
- Color-coded borders: Each user has a unique colored border (3px solid)
- Overlapping layout: Uses negative margin (
-space-x-3) for compact display - Responsive: Hidden on mobile (
.collaborators-listhashidden sm:flex)
Usage Example
In CollaborativeRoom Header
Fromcomponents/CollaborativeRoom.tsx:
Standalone Usage
Implementation
The component uses LiveblocksuseOthers() hook to access presence data:
User Info Structure
Each collaborator object contains:id: Unique user identifieravatar: URL to user’s profile image (from Clerk)name: Full name of the usercolor: Unique color assigned to the user (viagetUserColor())
Styling
Avatar Styling
List Container
Fromapp/globals.css:
Liveblocks Integration
This component must be used within a
RoomProvider and ClientSideSuspense wrapper to access Liveblocks presence data.useOthers() hook provides:
- Real-time updates when users join/leave
- Access to each user’s
infoobject (set during authentication) - Automatic cleanup on component unmount
Color Assignment
User colors are assigned in the Liveblocks auth endpoint:Related Components
- CollaborativeRoom - Parent component that uses ActiveCollaborators
- ShareModal - Shows all collaborators with permission management
- Header - Application header where ActiveCollaborators is typically displayed
Related Integrations
- Liveblocks - Real-time collaboration platform
- Clerk - User authentication and profile data
Source Reference
components/ActiveCollaborators.tsx