Skip to content
Brok UI

Loading…

No results

Leaderboard

Open source

A ranked leaderboard card with a top-three podium and a numbered list of entries showing avatar, name, team badge, score, and a movement indicator.

Responsive Dark mode RTL Localized SEO

Preview

resources/views/blocks/leaderboard.blade.php Blade
@props([
    'eyebrow' => 'This week',
    'heading' => 'Top contributors',
    'subheading' => 'Points earned across reviews, ships, and support — refreshed every hour.',
    'timeframe' => 'Weekly',
    'entries' => null,
])

@php
    $entries ??= [
        ['rank' => 1, 'name' => 'Avery Mitchell', 'initials' => 'AM', 'team' => 'Platform', 'score' => 4820, 'change' => 2],
        ['rank' => 2, 'name' => 'Jordan Lee', 'initials' => 'JL', 'team' => 'Core', 'score' => 4615, 'change' => 0],
        ['rank' => 3, 'name' => 'Priya Nair', 'initials' => 'PN', 'team' => 'Design', 'score' => 4390, 'change' => 1],
        ['rank' => 4, 'name' => 'Marcus Bell', 'initials' => 'MB', 'team' => 'Growth', 'score' => 3975, 'change' => -2],
        ['rank' => 5, 'name' => 'Sofia Reyes', 'initials' => 'SR', 'team' => 'Product', 'score' => 3640, 'change' => 3],
        ['rank' => 6, 'name' => 'Noah Carter', 'initials' => 'NC', 'team' => 'Support', 'score' => 3310, 'change' => -1],
        ['rank' => 7, 'name' => 'Lina Park', 'initials' => 'LP', 'team' => 'Core', 'score' => 3085, 'change' => 0],
        ['rank' => 8, 'name' => 'Diego Alvarez', 'initials' => 'DA', 'team' => 'Platform', 'score' => 2870, 'change' => -3],
    ];

    // Podium = first three entries; podium avatar size keyed by rank (no spliced classes).
    $podium = array_slice($entries, 0, 3);
    $podiumAvatarSize = [1 => 'xl', 2 => 'lg', 3 => 'lg'];
    $podiumOrder = [2 => 'order-1', 1 => 'order-2', 3 => 'order-3']; // 2nd, 1st, 3rd visually
@endphp

<x-ui.section
    space="xl" {{ $attributes }}
    aria-labelledby="leaderboard-01-heading"
    data-slot="leaderboard"
>
    <div class="mx-auto max-w-3xl px-4">
        <x-ui.card class="overflow-hidden p-0">
            <header class="flex flex-col gap-4 border-b border-border p-6 sm:flex-row sm:items-end sm:justify-between">
                <div>
                    @if ($eyebrow)
                        <p class="text-sm font-semibold uppercase tracking-wide text-primary">{{ __($eyebrow) }}</p>
                    @endif
                    <h2 id="leaderboard-01-heading" class="mt-2 text-balance text-2xl font-bold tracking-tight sm:text-3xl">
                        {{ __($heading) }}
                    </h2>
                    @if ($subheading)
                        <p class="mt-2 max-w-prose text-pretty text-sm text-muted-foreground">{{ __($subheading) }}</p>
                    @endif
                </div>
                @if ($timeframe)
                    <x-ui.badge variant="secondary" size="md" class="self-start sm:self-auto">{{ __($timeframe) }}</x-ui.badge>
                @endif
            </header>

            {{-- Top-three podium --}}
            <div class="grid grid-cols-3 items-end gap-4 bg-muted/40 px-6 py-8">
                @foreach ($podium as $top)
                    <figure class="{{ $podiumOrder[$top['rank']] ?? '' }} flex flex-col items-center text-center">
                        <span class="mb-2 flex size-6 items-center justify-center rounded-full bg-primary/10 text-sm font-bold text-primary">
                            {{ $top['rank'] }}
                        </span>
                        <x-ui.avatar
                            :size="$podiumAvatarSize[$top['rank']] ?? 'lg'"
                            :alt="$top['name']"
                            :fallback="$top['initials']"
                            class="ring-2 ring-border ring-offset-2 ring-offset-background"
                        />
                        <figcaption class="mt-4 w-full">
                            <span class="block truncate text-sm font-semibold text-foreground">{{ __($top['name']) }}</span>
                            <span class="block text-sm font-semibold tabular-nums text-muted-foreground">
                                {{ number_format($top['score']) }}
                            </span>
                        </figcaption>
                    </figure>
                @endforeach
            </div>

            {{-- Full ranked list --}}
            <ol role="list" class="divide-y divide-border">
                @foreach ($entries as $entry)
                    @php
                        $change = (int) $entry['change'];
                        $isUp = $change > 0;
                        $isDown = $change < 0;
                    @endphp
                    <li class="flex items-center gap-4 px-6 py-4">
                        <span class="w-6 shrink-0 text-end text-sm font-semibold tabular-nums text-muted-foreground" aria-hidden="true">
                            {{ $entry['rank'] }}
                        </span>

                        <x-ui.avatar
                            size="sm"
                            :alt="$entry['name']"
                            :fallback="$entry['initials']"
                            class="shrink-0"
                        />

                        <div class="min-w-0 flex-1">
                            <p class="truncate text-sm font-medium text-foreground">
                                <span class="sr-only">{{ __('Rank :n:', ['n' => $entry['rank']]) }}</span>
                                {{ __($entry['name']) }}
                            </p>
                            @if (! empty($entry['team']))
                                <x-ui.badge variant="outline" size="sm" class="mt-2">{{ __($entry['team']) }}</x-ui.badge>
                            @endif
                        </div>

                        <span class="shrink-0 text-base font-semibold tabular-nums text-foreground">
                            {{ number_format($entry['score']) }}
                            <span class="sr-only">{{ __('points') }}</span>
                        </span>

                        <span
                            @class([
                                'flex w-12 shrink-0 items-center justify-end gap-0.5 text-sm font-semibold tabular-nums',
                                'text-success' => $isUp,
                                'text-destructive' => $isDown,
                                'text-muted-foreground' => ! $isUp && ! $isDown,
                            ])
                        >
                            @if ($isUp)
                                <svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                    <path d="M12 19V5M5 12l7-7 7 7" />
                                </svg>
                                <span>{{ abs($change) }}</span>
                                <span class="sr-only">{{ __('up :n places', ['n' => abs($change)]) }}</span>
                            @elseif ($isDown)
                                <svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                    <path d="M12 5v14M5 12l7 7 7-7" />
                                </svg>
                                <span>{{ abs($change) }}</span>
                                <span class="sr-only">{{ __('down :n places', ['n' => abs($change)]) }}</span>
                            @else
                                <svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                    <path d="M5 12h14" />
                                </svg>
                                <span class="sr-only">{{ __('no change') }}</span>
                            @endif
                        </span>
                    </li>
                @endforeach
            </ol>
        </x-ui.card>
    </div>
</x-ui.section>

Installation

terminal
php artisan ui:add blocks/leaderboard

Installs these dependencies automatically:

Registry contract

Install confidence

php artisan ui:add blocks/leaderboard 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.5
License
open
Stability
stable
Contract
v1
Foundation
≥ 1.0.0
Type Generated target
blade resources/views/blocks/leaderboard.blade.php

Registry dependencies

avatar badge card section

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.

leaderboard.md
# Brok UI block: Leaderboard (`leaderboard`)

A ranked leaderboard card with a top-three podium and a numbered list of entries showing avatar, name, team badge, score, and a movement indicator.

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/leaderboard
```

## Render it

```blade
<x-blocks.leaderboard />
```

## Props

- `eyebrow` (string, default `This week`) — Small uppercase label above the heading.
- `heading` (string, default `Top contributors`) — Primary section heading.
- `subheading` (string, default `Points earned across reviews, ships, and support — refreshed every hour.`) — Supporting paragraph under the heading.
- `timeframe` (string, default `Weekly`) — Badge label describing the ranking period; falsy hides the badge.
- `entries` (mixed|null, default `null`) — Array of {rank, name, initials, team, score, change} rows; falls back to an 8-entry sample leaderboard when null.

## Use when

- Use it to display a ranked leaderboard with a top-three podium (avatars sized by rank) followed by a full numbered list showing avatar, name, team badge, score, and rank-change indicator.
- Reach for it for contests, gamification, or contributor/points-based rankings where movement (up/down) matters as much as the raw score.

## Avoid when

- Avoid it for a simple list without ranking or scores; use a plain card/list block instead.

## Rules

- Render the installed block with `<x-blocks.leaderboard />` 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/leaderboard
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/leaderboard.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

  • Use it to display a ranked leaderboard with a top-three podium (avatars sized by rank) followed by a full numbered list showing avatar, name, team badge, score, and rank-change indicator.
  • Reach for it for contests, gamification, or contributor/points-based rankings where movement (up/down) matters as much as the raw score.

Avoid when

  • Avoid it for a simple list without ranking or scores; use a plain card/list block instead.

Anti-patterns

  • Do not replace semantic props with conflicting utility classes.
  • Do not remove labels, focus styles, or state attributes.
Anatomy
header with eyebrow, heading, subheading, and timeframe badge top-three podium with ranked avatars ranked entry list entry avatar, name, and team badge score rank-change indicator

Usage

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

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

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/leaderboard.blade.php Blade
@props([
    'eyebrow' => 'This week',
    'heading' => 'Top contributors',
    'subheading' => 'Points earned across reviews, ships, and support — refreshed every hour.',
    'timeframe' => 'Weekly',
    'entries' => null,
])

@php
    $entries ??= [
        ['rank' => 1, 'name' => 'Avery Mitchell', 'initials' => 'AM', 'team' => 'Platform', 'score' => 4820, 'change' => 2],
        ['rank' => 2, 'name' => 'Jordan Lee', 'initials' => 'JL', 'team' => 'Core', 'score' => 4615, 'change' => 0],
        ['rank' => 3, 'name' => 'Priya Nair', 'initials' => 'PN', 'team' => 'Design', 'score' => 4390, 'change' => 1],
        ['rank' => 4, 'name' => 'Marcus Bell', 'initials' => 'MB', 'team' => 'Growth', 'score' => 3975, 'change' => -2],
        ['rank' => 5, 'name' => 'Sofia Reyes', 'initials' => 'SR', 'team' => 'Product', 'score' => 3640, 'change' => 3],
        ['rank' => 6, 'name' => 'Noah Carter', 'initials' => 'NC', 'team' => 'Support', 'score' => 3310, 'change' => -1],
        ['rank' => 7, 'name' => 'Lina Park', 'initials' => 'LP', 'team' => 'Core', 'score' => 3085, 'change' => 0],
        ['rank' => 8, 'name' => 'Diego Alvarez', 'initials' => 'DA', 'team' => 'Platform', 'score' => 2870, 'change' => -3],
    ];

    // Podium = first three entries; podium avatar size keyed by rank (no spliced classes).
    $podium = array_slice($entries, 0, 3);
    $podiumAvatarSize = [1 => 'xl', 2 => 'lg', 3 => 'lg'];
    $podiumOrder = [2 => 'order-1', 1 => 'order-2', 3 => 'order-3']; // 2nd, 1st, 3rd visually
@endphp

<x-ui.section
    space="xl" {{ $attributes }}
    aria-labelledby="leaderboard-01-heading"
    data-slot="leaderboard"
>
    <div class="mx-auto max-w-3xl px-4">
        <x-ui.card class="overflow-hidden p-0">
            <header class="flex flex-col gap-4 border-b border-border p-6 sm:flex-row sm:items-end sm:justify-between">
                <div>
                    @if ($eyebrow)
                        <p class="text-sm font-semibold uppercase tracking-wide text-primary">{{ __($eyebrow) }}</p>
                    @endif
                    <h2 id="leaderboard-01-heading" class="mt-2 text-balance text-2xl font-bold tracking-tight sm:text-3xl">
                        {{ __($heading) }}
                    </h2>
                    @if ($subheading)
                        <p class="mt-2 max-w-prose text-pretty text-sm text-muted-foreground">{{ __($subheading) }}</p>
                    @endif
                </div>
                @if ($timeframe)
                    <x-ui.badge variant="secondary" size="md" class="self-start sm:self-auto">{{ __($timeframe) }}</x-ui.badge>
                @endif
            </header>

            {{-- Top-three podium --}}
            <div class="grid grid-cols-3 items-end gap-4 bg-muted/40 px-6 py-8">
                @foreach ($podium as $top)
                    <figure class="{{ $podiumOrder[$top['rank']] ?? '' }} flex flex-col items-center text-center">
                        <span class="mb-2 flex size-6 items-center justify-center rounded-full bg-primary/10 text-sm font-bold text-primary">
                            {{ $top['rank'] }}
                        </span>
                        <x-ui.avatar
                            :size="$podiumAvatarSize[$top['rank']] ?? 'lg'"
                            :alt="$top['name']"
                            :fallback="$top['initials']"
                            class="ring-2 ring-border ring-offset-2 ring-offset-background"
                        />
                        <figcaption class="mt-4 w-full">
                            <span class="block truncate text-sm font-semibold text-foreground">{{ __($top['name']) }}</span>
                            <span class="block text-sm font-semibold tabular-nums text-muted-foreground">
                                {{ number_format($top['score']) }}
                            </span>
                        </figcaption>
                    </figure>
                @endforeach
            </div>

            {{-- Full ranked list --}}
            <ol role="list" class="divide-y divide-border">
                @foreach ($entries as $entry)
                    @php
                        $change = (int) $entry['change'];
                        $isUp = $change > 0;
                        $isDown = $change < 0;
                    @endphp
                    <li class="flex items-center gap-4 px-6 py-4">
                        <span class="w-6 shrink-0 text-end text-sm font-semibold tabular-nums text-muted-foreground" aria-hidden="true">
                            {{ $entry['rank'] }}
                        </span>

                        <x-ui.avatar
                            size="sm"
                            :alt="$entry['name']"
                            :fallback="$entry['initials']"
                            class="shrink-0"
                        />

                        <div class="min-w-0 flex-1">
                            <p class="truncate text-sm font-medium text-foreground">
                                <span class="sr-only">{{ __('Rank :n:', ['n' => $entry['rank']]) }}</span>
                                {{ __($entry['name']) }}
                            </p>
                            @if (! empty($entry['team']))
                                <x-ui.badge variant="outline" size="sm" class="mt-2">{{ __($entry['team']) }}</x-ui.badge>
                            @endif
                        </div>

                        <span class="shrink-0 text-base font-semibold tabular-nums text-foreground">
                            {{ number_format($entry['score']) }}
                            <span class="sr-only">{{ __('points') }}</span>
                        </span>

                        <span
                            @class([
                                'flex w-12 shrink-0 items-center justify-end gap-0.5 text-sm font-semibold tabular-nums',
                                'text-success' => $isUp,
                                'text-destructive' => $isDown,
                                'text-muted-foreground' => ! $isUp && ! $isDown,
                            ])
                        >
                            @if ($isUp)
                                <svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                    <path d="M12 19V5M5 12l7-7 7 7" />
                                </svg>
                                <span>{{ abs($change) }}</span>
                                <span class="sr-only">{{ __('up :n places', ['n' => abs($change)]) }}</span>
                            @elseif ($isDown)
                                <svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                    <path d="M12 5v14M5 12l7 7 7-7" />
                                </svg>
                                <span>{{ abs($change) }}</span>
                                <span class="sr-only">{{ __('down :n places', ['n' => abs($change)]) }}</span>
                            @else
                                <svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                    <path d="M5 12h14" />
                                </svg>
                                <span class="sr-only">{{ __('no change') }}</span>
                            @endif
                        </span>
                    </li>
                @endforeach
            </ol>
        </x-ui.card>
    </div>
</x-ui.section>

Ownership & lifecycle

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