Skip to content
Brok UI

Loading…

No results

Chat List

Open source

Filterable conversation inbox sidebar with presence indicators, unread badges, and active-row highlight.

Responsive Dark mode RTL Localized SEO

Preview

resources/views/blocks/chat-list.blade.php Blade
@props([
    'title' => 'Messages',
])

{{--
    Chat List 01 — Conversation inbox / chat-list sidebar.
    Interactive: Alpine x-data with search filter, active conversation tracking,
    and per-row presence + unread badge. Each row composes <x-ui.avatar>, with
    the initials bound via x-text so Alpine can render them from the client-side
    conversation list.
--}}
<x-ui.section
    data-slot="block-chat-list"
    aria-label="{{ __($title) }}"
    space="lg" {{ $attributes }}
>
    <div class="mx-auto flex max-w-sm flex-col px-4">
        <div
            x-data="{
                q: '',
                active: 1,
                conversations: [
                    { id: 1, name: 'Alice Martin',    initials: 'AM', preview: 'Sounds good, I\'ll send the file over.',   time: '2m',  unread: 3, online: true  },
                    { id: 2, name: 'Bob Chen',         initials: 'BC', preview: 'Can we reschedule the call tomorrow?',     time: '14m', unread: 1, online: false },
                    { id: 3, name: 'Design Team',      initials: 'DT', preview: 'Final mockups are ready for review 🎉',    time: '1h',  unread: 0, online: true  },
                    { id: 4, name: 'Carlos Rivera',    initials: 'CR', preview: 'Thanks for the update!',                  time: '3h',  unread: 0, online: false },
                    { id: 5, name: 'Engineering Guild', initials: 'EG', preview: 'Deploy is scheduled for Friday morning.',  time: '5h',  unread: 7, online: true  },
                    { id: 6, name: 'Priya Sharma',     initials: 'PS', preview: 'Loved the presentation — well done.',     time: '1d',  unread: 0, online: false },
                ],
                get filtered() {
                    const s = this.q.toLowerCase();
                    return this.conversations.filter(c =>
                        c.name.toLowerCase().includes(s) || c.preview.toLowerCase().includes(s)
                    );
                },
                init() {},
                destroy() {},
            }"
            class="overflow-hidden rounded-lg border border-border bg-card text-card-foreground shadow-sm"
        >
            {{-- Header --}}
            <header class="flex items-center justify-between gap-4 border-b border-border px-4 py-4">
                <div class="flex items-center gap-2">
                    <h2 class="text-base font-semibold text-foreground">{{ __($title) }}</h2>
                </div>
                <x-ui.button size="icon" variant="ghost" aria-label="{{ __('New chat') }}">
                    {{-- Pencil-square icon --}}
                    <svg class="size-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                        <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
                        <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />
                    </svg>
                </x-ui.button>
            </header>

            {{-- Search --}}
            <div class="px-4 py-4">
                <x-ui.input-group>
                    <x-ui.input-group.addon><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8" /><path d="m21 21-4.35-4.35" /></svg></x-ui.input-group.addon>
                    <x-ui.input-group.input
                        type="search"
                        x-model="q"
                        placeholder="{{ __('Search…') }}"
                        aria-label="{{ __('Search conversations') }}"
                    />
                </x-ui.input-group>
            </div>

            {{-- Conversation list --}}
            <ul
                role="list"
                class="max-h-[26rem] overflow-y-auto divide-y divide-border"
                aria-label="{{ __('Conversations') }}"
            >
                <template x-for="c in filtered" :key="c.id">
                    <li role="listitem">
                        <button
                            type="button"
                            class="w-full px-4 py-4 text-start transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
                            :class="active === c.id ? 'bg-accent' : 'hover:bg-accent/50'"
                            x-on:click="active = c.id"
                            :aria-pressed="active === c.id"
                            :aria-label="c.name"
                        >
                            <div class="flex items-center gap-4">
                                <div class="relative shrink-0">
                                    <x-ui.avatar>
                                        <span x-text="c.initials"></span>
                                    </x-ui.avatar>
                                    {{-- Presence dot --}}
                                    <span
                                        x-show="c.online"
                                        class="absolute bottom-0 end-0 size-2 rounded-full bg-success ring-2 ring-card"
                                        aria-hidden="true"
                                    ></span>
                                </div>

                                <div class="min-w-0 flex-1">
                                    <div class="flex items-center gap-2">
                                        <span class="flex-1 truncate text-sm font-medium text-foreground" x-text="c.name"></span>
                                        <span class="ms-auto shrink-0 text-xs text-muted-foreground" x-text="c.time"></span>
                                    </div>
                                    <div class="mt-0.5 flex items-center gap-2">
                                        <span class="flex-1 truncate text-xs text-muted-foreground" x-text="c.preview"></span>
                                        {{-- Unread badge --}}
                                        <span
                                            x-show="c.unread > 0"
                                            x-text="c.unread"
                                            class="ms-auto inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-primary text-xs font-semibold text-primary-foreground"
                                            aria-label="{{ __('unread messages') }}"
                                        ></span>
                                    </div>
                                </div>
                            </div>
                        </button>
                    </li>
                </template>

                {{-- Empty state --}}
                <li x-show="filtered.length === 0" class="px-4 py-8 text-center text-sm text-muted-foreground">
                    {{ __('No conversations found.') }}
                </li>
            </ul>
        </div>
    </div>
</x-ui.section>

Installation

terminal
php artisan ui:add blocks/chat-list

Installs these dependencies automatically:

Registry contract

Install confidence

php artisan ui:add blocks/chat-list writes only the generated targets below. The CLI validates each file hash before writing and prompts before replacing local changes unless --force is used.

Version
1.0.7
License
open
Stability
stable
Contract
v1
Foundation
≥ 1.0.0
Type Generated target
blade resources/views/blocks/chat-list.blade.php

Registry dependencies

avatar button section input-group

Package dependencies

composer: jml/brok:^0.2

Use with AI

A brief for your coding agent: what the block is, the install command, how to render it, its props and the rules. Copy it, or open a prompt about this block in an assistant.

chat-list.md
# Brok UI block: Chat List (`chat-list`)

Filterable conversation inbox sidebar with presence indicators, unread badges, and active-row highlight.

Brok UI is a Laravel Blade registry. `ui:add` copies this block into the app as plain Blade the app owns; it composes installed `<brok:*>` primitives and semantic design tokens.

## Install

```bash
php artisan ui:add blocks/chat-list
```

## Render it

```blade
<x-blocks.chat-list />
```

## Props

- `title` (string, default `Messages`)

## Use when

- Building a conversation-inbox sidebar with presence dots, unread badges and an active-row highlight per conversation.
- Letting a visitor filter the conversation list live by name or message preview.

## Avoid when

- Use chat-demo for a single static conversation panel rather than a filterable list of many conversations.

## Rules

- Render the installed block with `<x-blocks.chat-list />` and pass data through its props; edit the copied file only for structural changes.
- Keep the semantic design tokens (`bg-background`, `text-muted-foreground`); never swap in raw colour utilities.
- Keep the `data-slot` attributes and the logical (start/end) spacing so the markup still mirrors under `dir="rtl"`.

## Links

- Docs: https://brokui.dev/blocks/chat-list
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/chat-list.json

Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.

Guidance

Use when

  • Building a conversation-inbox sidebar with presence dots, unread badges and an active-row highlight per conversation.
  • Letting a visitor filter the conversation list live by name or message preview.

Avoid when

  • Use chat-demo for a single static conversation panel rather than a filterable list of many conversations.

Anti-patterns

  • Do not replace semantic props with conflicting utility classes.
  • Do not remove labels, focus styles, or state attributes.
Anatomy
root block-chat-list

Usage

Render the block as a component, passing data where useful:

resources/views/welcome.blade.php Blade
<x-blocks.chat-list />

Built from primitives

Composes <brok:*> Semantic tokens Re-themeable RTL-ready

This block composes installed <brok:*> primitives and semantic design tokens only — it does not reimplement any primitive. Re-theme it (light, dark, admin, customer) by editing CSS variables; flip the preview to RTL to confirm it mirrors.

Source

The exact, editable file ui:add writes into your app. The preview above renders this same source — there are no preview-only blocks.

resources/views/blocks/chat-list.blade.php Blade
@props([
    'title' => 'Messages',
])

{{--
    Chat List 01 — Conversation inbox / chat-list sidebar.
    Interactive: Alpine x-data with search filter, active conversation tracking,
    and per-row presence + unread badge. Each row composes <x-ui.avatar>, with
    the initials bound via x-text so Alpine can render them from the client-side
    conversation list.
--}}
<x-ui.section
    data-slot="block-chat-list"
    aria-label="{{ __($title) }}"
    space="lg" {{ $attributes }}
>
    <div class="mx-auto flex max-w-sm flex-col px-4">
        <div
            x-data="{
                q: '',
                active: 1,
                conversations: [
                    { id: 1, name: 'Alice Martin',    initials: 'AM', preview: 'Sounds good, I\'ll send the file over.',   time: '2m',  unread: 3, online: true  },
                    { id: 2, name: 'Bob Chen',         initials: 'BC', preview: 'Can we reschedule the call tomorrow?',     time: '14m', unread: 1, online: false },
                    { id: 3, name: 'Design Team',      initials: 'DT', preview: 'Final mockups are ready for review 🎉',    time: '1h',  unread: 0, online: true  },
                    { id: 4, name: 'Carlos Rivera',    initials: 'CR', preview: 'Thanks for the update!',                  time: '3h',  unread: 0, online: false },
                    { id: 5, name: 'Engineering Guild', initials: 'EG', preview: 'Deploy is scheduled for Friday morning.',  time: '5h',  unread: 7, online: true  },
                    { id: 6, name: 'Priya Sharma',     initials: 'PS', preview: 'Loved the presentation — well done.',     time: '1d',  unread: 0, online: false },
                ],
                get filtered() {
                    const s = this.q.toLowerCase();
                    return this.conversations.filter(c =>
                        c.name.toLowerCase().includes(s) || c.preview.toLowerCase().includes(s)
                    );
                },
                init() {},
                destroy() {},
            }"
            class="overflow-hidden rounded-lg border border-border bg-card text-card-foreground shadow-sm"
        >
            {{-- Header --}}
            <header class="flex items-center justify-between gap-4 border-b border-border px-4 py-4">
                <div class="flex items-center gap-2">
                    <h2 class="text-base font-semibold text-foreground">{{ __($title) }}</h2>
                </div>
                <x-ui.button size="icon" variant="ghost" aria-label="{{ __('New chat') }}">
                    {{-- Pencil-square icon --}}
                    <svg class="size-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                        <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
                        <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />
                    </svg>
                </x-ui.button>
            </header>

            {{-- Search --}}
            <div class="px-4 py-4">
                <x-ui.input-group>
                    <x-ui.input-group.addon><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8" /><path d="m21 21-4.35-4.35" /></svg></x-ui.input-group.addon>
                    <x-ui.input-group.input
                        type="search"
                        x-model="q"
                        placeholder="{{ __('Search…') }}"
                        aria-label="{{ __('Search conversations') }}"
                    />
                </x-ui.input-group>
            </div>

            {{-- Conversation list --}}
            <ul
                role="list"
                class="max-h-[26rem] overflow-y-auto divide-y divide-border"
                aria-label="{{ __('Conversations') }}"
            >
                <template x-for="c in filtered" :key="c.id">
                    <li role="listitem">
                        <button
                            type="button"
                            class="w-full px-4 py-4 text-start transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
                            :class="active === c.id ? 'bg-accent' : 'hover:bg-accent/50'"
                            x-on:click="active = c.id"
                            :aria-pressed="active === c.id"
                            :aria-label="c.name"
                        >
                            <div class="flex items-center gap-4">
                                <div class="relative shrink-0">
                                    <x-ui.avatar>
                                        <span x-text="c.initials"></span>
                                    </x-ui.avatar>
                                    {{-- Presence dot --}}
                                    <span
                                        x-show="c.online"
                                        class="absolute bottom-0 end-0 size-2 rounded-full bg-success ring-2 ring-card"
                                        aria-hidden="true"
                                    ></span>
                                </div>

                                <div class="min-w-0 flex-1">
                                    <div class="flex items-center gap-2">
                                        <span class="flex-1 truncate text-sm font-medium text-foreground" x-text="c.name"></span>
                                        <span class="ms-auto shrink-0 text-xs text-muted-foreground" x-text="c.time"></span>
                                    </div>
                                    <div class="mt-0.5 flex items-center gap-2">
                                        <span class="flex-1 truncate text-xs text-muted-foreground" x-text="c.preview"></span>
                                        {{-- Unread badge --}}
                                        <span
                                            x-show="c.unread > 0"
                                            x-text="c.unread"
                                            class="ms-auto inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-primary text-xs font-semibold text-primary-foreground"
                                            aria-label="{{ __('unread messages') }}"
                                        ></span>
                                    </div>
                                </div>
                            </div>
                        </button>
                    </li>
                </template>

                {{-- Empty state --}}
                <li x-show="filtered.length === 0" class="px-4 py-8 text-center text-sm text-muted-foreground">
                    {{ __('No conversations found.') }}
                </li>
            </ul>
        </div>
    </div>
</x-ui.section>

Ownership & lifecycle

Owner, release state, review evidence and adoption for this item.
Owner
Platform UI (@JoshJML)
Current version
1.0.7
Status
Stable
License
open
Deprecation
Not deprecated
Contract
v1
Foundation
≥ 1.0.0