Skip to content
Brok UI

Loading…

No results

Todo List

Open source

A task list card with a progress summary, an add-task input row, and a list of checkbox task rows with priority badges and due dates.

Responsive Dark mode RTL Localized SEO

Preview

resources/views/blocks/todo-list.blade.php Blade
@props([
    'heading' => 'Today’s tasks',
    'tasks' => null,
])

@php
    // Seeded sample tasks. `done` drives both the checked state and the
    // completed/struck-through styling inside <x-ui.todo-item>.
    $tasks ??= [
        ['title' => 'Finalise the Q3 launch announcement', 'priority' => 'high', 'due' => 'Today', 'done' => false],
        ['title' => 'Review the open pull request', 'priority' => 'medium', 'due' => 'Today', 'done' => false],
        ['title' => 'Reply to the Acme Inc. onboarding email', 'priority' => 'medium', 'due' => 'Tomorrow', 'done' => false],
        ['title' => 'Draft the sprint retro agenda', 'priority' => 'low', 'due' => 'Thu', 'done' => false],
        ['title' => 'Update the design-token documentation', 'priority' => 'low', 'due' => 'Fri', 'done' => true],
        ['title' => 'Sync with the platform team', 'priority' => 'medium', 'due' => 'Mon', 'done' => true],
        ['title' => 'Archive the closed support tickets', 'priority' => 'low', 'due' => null, 'done' => true],
    ];

    $total = count($tasks);
    $completed = collect($tasks)->where('done', true)->count();
    $remaining = $total - $completed;
    $pct = $total > 0 ? round($completed / $total * 100) : 0;
@endphp

<x-ui.section
    data-slot="todo-list"
    aria-labelledby="todo-list-01-heading"
    space="xl" {{ $attributes }}
>
    <div class="mx-auto max-w-xl px-4">
        <x-ui.card>
            <x-ui.card.header>
                <div class="flex items-start justify-between gap-4">
                    <div>
                        <h2 id="todo-list-01-heading" class="text-lg font-semibold leading-none tracking-tight" data-slot="card-title">{{ __($heading) }}</h2>
                        <x-ui.card.description>
                            {{ __(':completed of :total done', ['completed' => $completed, 'total' => $total]) }}
                        </x-ui.card.description>
                    </div>
                    <x-ui.badge variant="secondary" class="shrink-0">
                        {{ __(':count left', ['count' => $remaining]) }}
                    </x-ui.badge>
                </div>

                <div class="mt-4">
                    <x-ui.progress
                        :value="$pct"
                        tone="success"
                        :aria-label="__('Tasks completed')"
                    />
                </div>
            </x-ui.card.header>

            <x-ui.card.content class="space-y-4">
                {{-- Add-task row. Decorative composition of input + button; no submit handler. --}}
                <form action="#" method="POST" class="flex items-center gap-2">
                    @csrf
                    <label for="todo-list-01-add" class="sr-only">{{ __('Add a task') }}</label>
                    <x-ui.input
                        id="todo-list-01-add"
                        name="task"
                        type="text"
                        autocomplete="off"
                        :placeholder="__('Add a task…')"
                        class="flex-1"
                    />
                    <x-ui.button type="submit" :aria-label="__('Add task')">
                        <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4">
                            <path d="M12 5v14M5 12h14" />
                        </svg>
                        <span class="ms-0.5">{{ __('Add') }}</span>
                    </x-ui.button>
                </form>

                <ul role="list" class="space-y-2">
                    @foreach ($tasks as $task)
                        <li>
                            <x-ui.todo-item
                                :title="$task['title']"
                                :priority="$task['priority']"
                                :due="$task['due'] ? __($task['due']) : null"
                                :done="$task['done']"
                            />
                        </li>
                    @endforeach
                </ul>
            </x-ui.card.content>
        </x-ui.card>
    </div>
</x-ui.section>

Installation

terminal
php artisan ui:add blocks/todo-list

Registry contract

Install confidence

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

Registry dependencies

badge button card checkbox input progress section todo-item

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.

todo-list.md
# Brok UI block: Todo List (`todo-list`)

A task list card with a progress summary, an add-task input row, and a list of checkbox task rows with priority badges and due dates.

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/todo-list
```

## Render it

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

## Props

- `heading` (string, default `Today’s tasks`) — Section heading.
- `tasks` (mixed|null, default `null`) — Task rows with title, priority, due date and done state; null falls back to sample data.

## Use when

- Showing a task list card with a progress summary, an add-task input and checkbox rows with priority and due date.
- Building a personal or team todo widget inside an app.

## Avoid when

- Needing a full project management board instead of a simple list; compose a different layout from primitives instead.
- Needing a read-only day-planner summary instead of an editable checklist; use productivity-widget-planner instead.

## Rules

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

  • Showing a task list card with a progress summary, an add-task input and checkbox rows with priority and due date.
  • Building a personal or team todo widget inside an app.

Avoid when

  • Needing a full project management board instead of a simple list; compose a different layout from primitives instead.
  • Needing a read-only day-planner summary instead of an editable checklist; use productivity-widget-planner instead.

Anti-patterns

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

Usage

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

resources/views/welcome.blade.php Blade
<x-blocks.todo-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/todo-list.blade.php Blade
@props([
    'heading' => 'Today’s tasks',
    'tasks' => null,
])

@php
    // Seeded sample tasks. `done` drives both the checked state and the
    // completed/struck-through styling inside <x-ui.todo-item>.
    $tasks ??= [
        ['title' => 'Finalise the Q3 launch announcement', 'priority' => 'high', 'due' => 'Today', 'done' => false],
        ['title' => 'Review the open pull request', 'priority' => 'medium', 'due' => 'Today', 'done' => false],
        ['title' => 'Reply to the Acme Inc. onboarding email', 'priority' => 'medium', 'due' => 'Tomorrow', 'done' => false],
        ['title' => 'Draft the sprint retro agenda', 'priority' => 'low', 'due' => 'Thu', 'done' => false],
        ['title' => 'Update the design-token documentation', 'priority' => 'low', 'due' => 'Fri', 'done' => true],
        ['title' => 'Sync with the platform team', 'priority' => 'medium', 'due' => 'Mon', 'done' => true],
        ['title' => 'Archive the closed support tickets', 'priority' => 'low', 'due' => null, 'done' => true],
    ];

    $total = count($tasks);
    $completed = collect($tasks)->where('done', true)->count();
    $remaining = $total - $completed;
    $pct = $total > 0 ? round($completed / $total * 100) : 0;
@endphp

<x-ui.section
    data-slot="todo-list"
    aria-labelledby="todo-list-01-heading"
    space="xl" {{ $attributes }}
>
    <div class="mx-auto max-w-xl px-4">
        <x-ui.card>
            <x-ui.card.header>
                <div class="flex items-start justify-between gap-4">
                    <div>
                        <h2 id="todo-list-01-heading" class="text-lg font-semibold leading-none tracking-tight" data-slot="card-title">{{ __($heading) }}</h2>
                        <x-ui.card.description>
                            {{ __(':completed of :total done', ['completed' => $completed, 'total' => $total]) }}
                        </x-ui.card.description>
                    </div>
                    <x-ui.badge variant="secondary" class="shrink-0">
                        {{ __(':count left', ['count' => $remaining]) }}
                    </x-ui.badge>
                </div>

                <div class="mt-4">
                    <x-ui.progress
                        :value="$pct"
                        tone="success"
                        :aria-label="__('Tasks completed')"
                    />
                </div>
            </x-ui.card.header>

            <x-ui.card.content class="space-y-4">
                {{-- Add-task row. Decorative composition of input + button; no submit handler. --}}
                <form action="#" method="POST" class="flex items-center gap-2">
                    @csrf
                    <label for="todo-list-01-add" class="sr-only">{{ __('Add a task') }}</label>
                    <x-ui.input
                        id="todo-list-01-add"
                        name="task"
                        type="text"
                        autocomplete="off"
                        :placeholder="__('Add a task…')"
                        class="flex-1"
                    />
                    <x-ui.button type="submit" :aria-label="__('Add task')">
                        <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4">
                            <path d="M12 5v14M5 12h14" />
                        </svg>
                        <span class="ms-0.5">{{ __('Add') }}</span>
                    </x-ui.button>
                </form>

                <ul role="list" class="space-y-2">
                    @foreach ($tasks as $task)
                        <li>
                            <x-ui.todo-item
                                :title="$task['title']"
                                :priority="$task['priority']"
                                :due="$task['due'] ? __($task['due']) : null"
                                :done="$task['done']"
                            />
                        </li>
                    @endforeach
                </ul>
            </x-ui.card.content>
        </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.4
Status
Stable
License
open
Deprecation
Not deprecated
Contract
v1
Foundation
≥ 1.0.0