Task

The Task component provides a structured way to display task lists or workflow progress with collapsible details, status indicators, and progress tracking. It consists of a main Task container with TaskTrigger for the clickable header and TaskContent for the collapsible content area.

Searching "src/routes/+page.svelte, components structure"
Read
svelte-logo +page.svelte
Scanning 47 files
Scanning 3 files
Reading file
svelte-logo +layout.svelte

Installation

pnpm dlx shadcn-svelte@latest add https://svelte-ai-elements.vercel.app/r/task.json

If you prefer using jsrepo, please install via the command below:

pnpm dlx jsrepo add @ai/elements/ai-elements/task

Usage

Usage with AI SDK

Build a mock async programming agent using experimental_useObject.

Add the following component to your frontend:

+page.svelte

Add the following route to your backend:

api/chat/+server.ts

Features

  • Visual icons for pending, in-progress, completed, and error states
  • Expandable content for task descriptions and additional information
  • Built-in progress counter showing completed vs total tasks
  • Optional progressive reveal of tasks with customizable timing
  • Support for custom content within task items
  • Full type safety with proper TypeScript definitions
  • Keyboard navigation and screen reader support

Props

Task

PropTypeDefaultDescription
openbooleantrueControls whether the task is expanded or collapsed (bindable)
classstring-Additional CSS classes to apply to the task container
childrenSnippet-Child components (typically TaskTrigger and TaskContent)
...restPropsCollapsibleProps-All other Collapsible component props are supported

TaskTrigger

PropTypeDefaultDescription
titlestring-The title text to display in the trigger
classstring-Additional CSS classes to apply to the trigger
childrenSnippet-Custom content to render instead of the default trigger layout
...restPropsCollapsibleTriggerProps-All other CollapsibleTrigger component props are supported

TaskContent

PropTypeDefaultDescription
classstring-Additional CSS classes to apply to the content container
childrenSnippet-Task items to display when expanded
...restPropsCollapsibleContentProps-All other CollapsibleContent component props are supported

TaskItem

PropTypeDefaultDescription
classstring-Additional CSS classes to apply to the task item
childrenSnippet-Content of the task item
...restPropsHTMLAttributes<HTMLDivElement>-All other div props are supported

TaskItemFile

PropTypeDefaultDescription
classstring-Additional CSS classes to apply to the file badge
childrenSnippet-File name or content to display
...restPropsHTMLAttributes<HTMLDivElement>-All other div props are supported