Todo Item
A single task row with a checkbox that strikes the title through on completion, plus optional due date, tags and a priority badge.
Preview
Finalise the launch announcement
Review pull request #482
Token migration for the chart suite.
Archive last quarter's boards
<div class="mx-auto w-full max-w-sm space-y-2">
<x-ui.todo-item
title="Finalise the launch announcement"
due="Today"
priority="high"
:tags="['Marketing']"
/>
<x-ui.todo-item
title="Review pull request #482"
description="Token migration for the chart suite."
due="Tomorrow"
priority="medium"
/>
<x-ui.todo-item
title="Archive last quarter's boards"
:done="true"
priority="low"
/>
</div>
Installation
php artisan ui:add todo-item
Use with AI
A brief for your coding agent: install command, usage, props, guidance and the rules. Copy it, or open a prompt about this component in an assistant.
# Brok UI: Todo Item (`todo-item`)
A single task row with a checkbox that strikes the title through on completion, plus optional due date, tags and a priority badge.
Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.
## Install
```bash
php artisan ui:add todo-item
```
## Usage
```blade
<div class="mx-auto w-full max-w-sm space-y-2">
<x-ui.todo-item
title="Finalise the launch announcement"
due="Today"
priority="high"
:tags="['Marketing']"
/>
<x-ui.todo-item
title="Review pull request #482"
description="Token migration for the chart suite."
due="Tomorrow"
priority="medium"
/>
<x-ui.todo-item
title="Archive last quarter's boards"
:done="true"
priority="low"
/>
</div>
```
## Props
- `title` (string, default `Draft the launch announcement`)
- `description` (mixed|null, default `null`)
- `done` (bool, default `false`)
- `priority` (mixed|null, default `null`)
- `due` (mixed|null, default `null`)
- `tags` (array, default `[]`)
## Use when
- Use when self-contained content objects benefit from a recognizable card-like presentation with local actions or metadata.
- Rendering one task in a to-do list with its done state, due date, tags and priority.
- Building a task list where each row must stay operable as a real checkbox.
## Avoid when
- Do not use card widgets where a simpler list, table, or plain text block would make comparison faster.
- Presenting a read-only step; timeline-steps or stepper show progress without a checkbox.
- Managing the list itself: ordering, filtering and persistence belong to the surrounding block.
## Anti-patterns
- Using cards for dense cross-item comparison
## Rules
- Use the `<brok:todo-item>` tag (or `<x-ui.todo-item>`) in Blade; do not rewrite the component.
- Prefer the documented props and variants over utility-class overrides; when a utility must win, use the `!` important modifier.
- Use semantic design tokens (`bg-primary`, `text-muted-foreground`), never raw colour utilities.
- Keep the `data-slot` attributes; they are the styling and test hooks.
## Links
- Docs: https://brokui.dev/docs/components/todo-item
- Registry JSON (files, props, contract): https://brokui.dev/r/open/todo-item.json
Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | Draft the launch announcement | |
| description | mixed | null | null | |
| done | bool | false | |
| priority | mixed | null | null | |
| due | mixed | null | null | |
| tags | array | [] |
Slots
default—
Data slots
Stable hooks for CSS overrides and browser tests.
Behavior
- The checkbox is a real checkbox primitive; checking it strikes the title through and mutes it with CSS alone.
- priority renders a badge in a matching variant, and due and tags render only when given.
- Declares registry capability flags: a11y, responsive, rtl, darkMode, localized.
Guidance
Present a self-contained content object with local context.
Use when
- Use when self-contained content objects benefit from a recognizable card-like presentation with local actions or metadata.
- Rendering one task in a to-do list with its done state, due date, tags and priority.
- Building a task list where each row must stay operable as a real checkbox.
Avoid when
- Do not use card widgets where a simpler list, table, or plain text block would make comparison faster.
- Presenting a read-only step; timeline-steps or stepper show progress without a checkbox.
- Managing the list itself: ordering, filtering and persistence belong to the surrounding block.
Use instead
- List for compact scanning
- Table for exact comparison
Anti-patterns
- Using cards for dense cross-item comparison
- Anatomy
- Theming hooks
Accessibility
- Keyboard
- No component-owned keyboard interaction; native element behavior applies.
- Focus
none
- The checkbox is labelled by the task title, so its purpose is announced with its state.
- Completion is conveyed by the checkbox state, with the strike-through as a visual echo.
- Semantic HTML and a stable
data-slotattribute for styling and scripting hooks. - Focus-visible rings use the
ringtoken, so keyboard focus is always visible. - Disabled and invalid states are conveyed to assistive tech, not by color alone.
- Targets WCAG 2.2 AA; verify contrast in light, dark, admin and customer surfaces in the preview.
- Labels go through
__()and layout uses logical properties (ms-*,text-start), so it mirrors underdir="rtl"— flip the preview to RTL to confirm. - Dark mode uses the same semantic tokens under the
darkclass; high contrast follows forced-color system tokens.
Livewire
Livewire can update this component through forwarded wire:* attributes.
Source
The exact, editable file ui:add writes
into your app. Previews render this same code; there are no preview-only components.
@props([
'title' => 'Draft the launch announcement',
'description' => null,
'done' => false,
'priority' => null,
'due' => null,
'tags' => [],
])
@php
$tags = is_array($tags) ? $tags : [];
// Priority → badge variant. Unknown/empty priority renders no badge.
$priorityVariants = [
'low' => 'secondary',
'medium' => 'warning',
'high' => 'destructive',
];
$priority = $priority !== null && isset($priorityVariants[$priority]) ? $priority : null;
$checkboxLabel = __('Mark “:title” complete', ['title' => $title]);
@endphp
{{--
Todo item — a single task row. The native checkbox carries `peer`, so ticking
it strikes the title through (and mutes it) live via `peer-checked:`, with no
JS. `done` sets the initial checked state. Title/description are auto-escaped;
optional due date and tags render in a muted meta row, priority as a badge.
--}}
<div
data-slot="todo-item"
@if ($done) data-done="true" @endif
{{ $attributes->merge(['class' => 'flex items-start gap-3 rounded-md border border-border bg-card p-3 text-foreground transition-colors hover:bg-accent/40']) }}
>
<x-ui.checkbox
class="peer mt-0.5 shrink-0"
:checked="$done"
:aria-label="$checkboxLabel"
/>
<div class="min-w-0 flex-1 peer-checked:[&_.todo-item-title]:text-muted-foreground peer-checked:[&_.todo-item-title]:line-through">
<div class="flex items-start justify-between gap-2">
<p class="todo-item-title text-sm font-medium leading-snug transition-colors">{{ $title }}</p>
@if ($priority)
<x-ui.badge :variant="$priorityVariants[$priority]" size="sm" class="shrink-0 capitalize">{{ __($priority) }}</x-ui.badge>
@endif
</div>
@if ($description)
<p class="mt-0.5 text-xs text-muted-foreground">{{ $description }}</p>
@endif
@if ($due || count($tags))
<div class="mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground">
@if ($due)
<span class="inline-flex items-center gap-1">
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="size-4">
<rect x="3" y="4" width="18" height="18" rx="2" />
<path d="M3 10h18M8 2v4M16 2v4" />
</svg>
{{ $due }}
</span>
@endif
@foreach ($tags as $tag)
<span class="inline-flex items-center gap-1">
<span class="size-2 rounded-full bg-primary" aria-hidden="true"></span>{{ $tag }}
</span>
@endforeach
</div>
@endif
</div>
</div>
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 - Accessibility reviewed
- No review date recorded
- Last breaking change
- No date recorded
- Deprecation
- Not deprecated
- Contract
-
v6 - Foundation
-
≥ 1.0.0