Skip to content
← UI Library

Agent plan

A task plan for AI agents with progress, live status icons and expandable subtasks.

Svelte 5 · Version 1.0.0 · Zero extra packages

Connect MCP

Live preview

Improve signup conversion

1 of 4 done
  1. Remove fields that are not needed before the first project.

Design decision

Showing the plan and its progress builds trust in long-running agent work. The active task opens by default. Original Svelte 5 implementation. No code was copied from the inspiring component.

Inspired by Agent Plan by @isaiahbjork on 21st.dev ↗

Source and integration

Pass tasks with id, title, status (done, active or pending), an optional description and optional subtasks. Click a status icon to change it.

You may copy and adapt this original SaaSCrisp implementation in personal and commercial websites.

AgentPlan.svelte
<script lang="ts">
	type Status = 'done' | 'active' | 'pending';
	type Subtask = { id: string; title: string; status: Status };
	type Task = { id: string; title: string; description?: string; status: Status; subtasks?: Subtask[] };
	let { tasks, title = 'Plan' }: { tasks: Task[]; title?: string } = $props();

	const id = $props.id();
	const next: Record<Status, Status> = { pending: 'active', active: 'done', done: 'pending' };
	const names: Record<Status, string> = { done: 'Done', active: 'In progress', pending: 'To do' };
	let overrides = $state<Record<string, Status>>({});
	let open = $state<Record<string, boolean>>({});

	const statusOf = (item: { id: string; status: Status }) => overrides[item.id] ?? item.status;
	const done = $derived(tasks.filter((task) => statusOf(task) === 'done').length);
	const firstActive = $derived(tasks.find((task) => statusOf(task) === 'active')?.id);
	const isOpen = (task: Task) => open[task.id] ?? task.id === firstActive;

	function cycle(item: { id: string; status: Status }) {
		overrides[item.id] = next[statusOf(item)];
	}
</script>

{#snippet icon(status: Status)}
	<span class="ag-status {status}" aria-hidden="true">
		{#if status === 'done'}
			<svg viewBox="0 0 24 24"><path d="M6 12.5l4 4 8-9" /></svg>
		{/if}
	</span>
{/snippet}

<section class="ag" aria-labelledby="{id}-title">
	<header>
		<h3 id="{id}-title">{title}</h3>
		<span class="ag-count">{done} of {tasks.length} done</span>
	</header>
	<div class="ag-progress" role="progressbar" aria-label="Plan progress" aria-valuemin={0} aria-valuemax={tasks.length} aria-valuenow={done}>
		<span style:width="{tasks.length ? (done / tasks.length) * 100 : 0}%"></span>
	</div>

	<ol>
		{#each tasks as task (task.id)}
			{@const status = statusOf(task)}
			<li class:muted={status === 'done'}>
				<div class="ag-row">
					<button class="ag-toggle" type="button" onclick={() => cycle(task)} aria-label="{task.title}: {names[status]}. Change status">
						{@render icon(status)}
					</button>
					<button
						class="ag-title"
						type="button"
						aria-expanded={isOpen(task)}
						aria-controls="{id}-{task.id}"
						onclick={() => (open[task.id] = !isOpen(task))}
					>
						<span>{task.title}</span>
						<span class="ag-tag {status}">{names[status]}</span>
						<svg class="ag-chev" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 6 6 6-6 6" /></svg>
					</button>
				</div>
				<div class="ag-body" class:open={isOpen(task)} id="{id}-{task.id}">
					<div>
						{#if task.description}<p>{task.description}</p>{/if}
						{#if task.subtasks?.length}
							<ul>
								{#each task.subtasks as subtask (subtask.id)}
									{@const subStatus = statusOf(subtask)}
									<li>
										<button type="button" class="ag-sub" onclick={() => cycle(subtask)} aria-label="{subtask.title}: {names[subStatus]}. Change status">
											{@render icon(subStatus)}
											<span class:struck={subStatus === 'done'}>{subtask.title}</span>
										</button>
									</li>
								{/each}
							</ul>
						{/if}
					</div>
				</div>
			</li>
		{/each}
	</ol>
</section>

<style>
	.ag {
		--_bg: var(--ui-bg, #ffffff);
		--_border: var(--ui-border, rgb(15 23 42 / 0.1));
		--_text: var(--ui-text, #0f172a);
		--_muted: var(--ui-muted, #64748b);
		--_accent: var(--ui-accent, #4f46e5);
		padding: 18px;
		border: 1px solid var(--_border);
		border-radius: 18px;
		background: var(--_bg);
		color: var(--_text);
		font-family: var(--ui-font, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif);
		text-align: left;
		box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.04);
	}
	header {
		display: flex;
		align-items: baseline;
		justify-content: space-between;
		gap: 12px;
	}
	h3 {
		margin: 0;
		color: var(--_text);
		font-size: 15px;
		font-weight: 600;
	}
	.ag-count {
		color: var(--_muted);
		font-size: 12px;
		font-variant-numeric: tabular-nums;
	}
	.ag-progress {
		height: 4px;
		margin: 12px 0 10px;
		overflow: hidden;
		border-radius: 999px;
		background: rgb(15 23 42 / 0.06);
	}
	.ag-progress span {
		display: block;
		height: 100%;
		border-radius: inherit;
		background: var(--_accent);
		transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
	}
	ol,
	ul {
		margin: 0;
		padding: 0;
		list-style: none;
	}
	.ag-row {
		display: flex;
		align-items: center;
		gap: 4px;
	}
	button {
		border: 0;
		background: none;
		color: inherit;
		font: inherit;
		cursor: pointer;
	}
	button:focus-visible {
		outline: 2px solid var(--_accent);
		outline-offset: 1px;
	}
	.ag-toggle {
		display: grid;
		place-items: center;
		width: 32px;
		height: 32px;
		border-radius: 8px;
	}
	.ag-title {
		display: flex;
		flex: 1;
		align-items: center;
		gap: 10px;
		min-width: 0;
		padding: 8px 8px 8px 4px;
		border-radius: 8px;
		font-size: 14px;
		font-weight: 500;
		text-align: left;
		transition: background-color 0.15s;
	}
	.ag-title:hover,
	.ag-toggle:hover {
		background: rgb(15 23 42 / 0.04);
	}
	.ag-title > span:first-child {
		flex: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.muted .ag-title > span:first-child {
		color: var(--_muted);
	}
	.ag-tag {
		flex-shrink: 0;
		padding: 2px 8px;
		border-radius: 999px;
		background: rgb(15 23 42 / 0.05);
		color: var(--_muted);
		font-size: 11px;
		font-weight: 500;
	}
	.ag-tag.active {
		background: color-mix(in srgb, var(--_accent) 12%, transparent);
		color: var(--_accent);
	}
	.ag-chev {
		flex-shrink: 0;
		width: 14px;
		height: 14px;
		fill: none;
		stroke: var(--_muted);
		stroke-width: 2;
		stroke-linecap: round;
		transition: rotate 0.25s;
	}
	[aria-expanded='true'] .ag-chev {
		rotate: 90deg;
	}
	.ag-status {
		display: grid;
		place-items: center;
		width: 18px;
		height: 18px;
		border: 1.5px dashed rgb(15 23 42 / 0.25);
		border-radius: 50%;
		transition:
			background-color 0.2s,
			border-color 0.2s;
	}
	.ag-status.active {
		border: 1.5px solid rgb(15 23 42 / 0.12);
		border-top-color: var(--_accent);
		animation: ag-spin 1s linear infinite;
	}
	.ag-status.done {
		border: 0;
		background: var(--_accent);
	}
	.ag-status svg {
		width: 12px;
		height: 12px;
		fill: none;
		stroke: #fff;
		stroke-width: 3;
		stroke-linecap: round;
		stroke-linejoin: round;
	}
	.ag-body {
		display: grid;
		grid-template-rows: 0fr;
		transition: grid-template-rows 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
	}
	.ag-body.open {
		grid-template-rows: 1fr;
	}
	.ag-body > div {
		min-height: 0;
		overflow: hidden;
		margin-left: 15px;
		padding-left: 22px;
		border-left: 1px solid var(--_border);
	}
	.ag-body.open > div {
		padding-bottom: 8px;
	}
	.ag-body p {
		margin: 2px 0 6px;
		color: var(--_muted);
		font-size: 13px;
		line-height: 1.5;
	}
	.ag-sub {
		display: flex;
		align-items: center;
		gap: 10px;
		width: 100%;
		padding: 6px 8px;
		border-radius: 8px;
		color: var(--_text);
		font-size: 13px;
		text-align: left;
	}
	.ag-sub:hover {
		background: rgb(15 23 42 / 0.04);
	}
	.ag-sub .ag-status {
		width: 15px;
		height: 15px;
	}
	.ag-sub .ag-status svg {
		width: 10px;
		height: 10px;
	}
	.struck {
		color: var(--_muted);
		text-decoration: line-through;
		text-decoration-color: rgb(15 23 42 / 0.25);
	}
	@keyframes ag-spin {
		to {
			rotate: 1turn;
		}
	}
	@media (prefers-reduced-motion: reduce) {
		.ag-status.active {
			animation: none;
		}
		.ag-body,
		.ag-progress span,
		.ag-chev {
			transition: none;
		}
	}
</style>
Agent prompt

Use the SaaSCrisp UI Library MCP at https://www.saascrisp.com/api/library/mcp. Retrieve agent-plan version 1.0.0 for svelte with get_ui_asset. Preview: https://www.saascrisp.com/library/agent-plan. Confirm the project's stack, reuse local primitives and map CSS variables to existing design tokens. Integrate the files and run the project's checks. Report changed files and additional dependencies.