Plan
shadcn/uiStructured execution plan displaying overall progress and expandable step details.
Plan1/4
x
Inspect registry schemas and exports140msAuthor interactive component examplesRunningFormat and verify lint rulesQueuedRun strict TypeScript checkQueued
Click to test live step progress
import { useState } from "react";import { Plan, PlanContent, PlanDescription, PlanHeader, PlanProgress, PlanStep, type PlanStepStatus, PlanTitle,} from "@/components/optics/ai-elements/plan";import { Button } from "@/components/optics/button";interface PlanStepItem { id: string; title: string; duration: string;}const PLAN_STEPS: PlanStepItem[] = [ { id: "audit", title: "Inspect registry schemas and exports", duration: "140ms", }, { id: "docs", title: "Author interactive component examples", duration: "420ms", }, { id: "lint", title: "Format and verify lint rules", duration: "180ms", }, { id: "types", title: "Run strict TypeScript check", duration: "610ms", },];function getStepStatus(index: number, completedCount: number): PlanStepStatus { if (index < completedCount) { return "completed"; } if (index === completedCount) { return "in-progress"; } return "pending";}function getStepDescription(status: PlanStepStatus, duration: string): string { switch (status) { case "completed": return duration; case "in-progress": return "Running"; case "pending": return "Queued"; case "error": return "Failed"; default: { const exhaustive: never = status; return exhaustive; } }}function PlanDemo() { const [completedCount, setCompletedCount] = useState(1); const isComplete = completedCount >= PLAN_STEPS.length; function handleAdvanceStep() { setCompletedCount((prev) => (prev >= PLAN_STEPS.length ? 1 : prev + 1)); } return ( <div className="flex w-full max-w-md flex-col gap-4 rounded-xl border bg-card p-5 text-card-foreground"> <Plan defaultOpen isStreaming={!isComplete}> <PlanHeader> <PlanTitle>Ship AI Elements documentation</PlanTitle> <PlanDescription> {completedCount} of {PLAN_STEPS.length} complete </PlanDescription> </PlanHeader> <PlanProgress completed={completedCount} total={PLAN_STEPS.length} /> <PlanContent> {PLAN_STEPS.map((step, index) => { const status = getStepStatus(index, completedCount); return ( <PlanStep key={step.id} status={status} description={getStepDescription(status, step.duration)} > {step.title} </PlanStep> ); })} </PlanContent> </Plan> <div className="flex items-center justify-between gap-3 border-t pt-3"> <span className="text-xs text-muted-foreground"> {isComplete ? "All steps completed" : "Click to test live step progress"} </span> <Button type="button" variant="outline" size="sm" onClick={handleAdvanceStep}> {isComplete ? "Reset progress" : "Advance step"} </Button> </div> </div> );}<PlanDemo />import { useState } from "react";import { Plan, PlanContent, PlanDescription, PlanHeader, PlanProgress, PlanStep, type PlanStepStatus, PlanTitle,} from "@/components/optics/ai-elements/plan";import { Button } from "@/components/optics/button";interface PlanStepItem { id: string; title: string; duration: string;}const PLAN_STEPS: PlanStepItem[] = [ { id: "audit", title: "Inspect registry schemas and exports", duration: "140ms", }, { id: "docs", title: "Author interactive component examples", duration: "420ms", }, { id: "lint", title: "Format and verify lint rules", duration: "180ms", }, { id: "types", title: "Run strict TypeScript check", duration: "610ms", },];function getStepStatus(index: number, completedCount: number): PlanStepStatus { if (index < completedCount) { return "completed"; } if (index === completedCount) { return "in-progress"; } return "pending";}function getStepDescription(status: PlanStepStatus, duration: string): string { switch (status) { case "completed": return duration; case "in-progress": return "Running"; case "pending": return "Queued"; case "error": return "Failed"; default: { const exhaustive: never = status; return exhaustive; } }}function PlanDemo() { const [completedCount, setCompletedCount] = useState(1); const isComplete = completedCount >= PLAN_STEPS.length; function handleAdvanceStep() { setCompletedCount((prev) => (prev >= PLAN_STEPS.length ? 1 : prev + 1)); } return ( <div className="flex w-full max-w-md flex-col gap-4 rounded-xl border bg-card p-5 text-card-foreground"> <Plan defaultOpen isStreaming={!isComplete}> <PlanHeader> <PlanTitle>Ship AI Elements documentation</PlanTitle> <PlanDescription> {completedCount} of {PLAN_STEPS.length} complete </PlanDescription> </PlanHeader> <PlanProgress completed={completedCount} total={PLAN_STEPS.length} /> <PlanContent> {PLAN_STEPS.map((step, index) => { const status = getStepStatus(index, completedCount); return ( <PlanStep key={step.id} status={status} description={getStepDescription(status, step.duration)} > {step.title} </PlanStep> ); })} </PlanContent> </Plan> <div className="flex items-center justify-between gap-3 border-t pt-3"> <span className="text-xs text-muted-foreground"> {isComplete ? "All steps completed" : "Click to test live step progress"} </span> <Button type="button" variant="outline" size="sm" onClick={handleAdvanceStep}> {isComplete ? "Reset progress" : "Advance step"} </Button> </div> </div> );}<PlanDemo />Installation
pnpm dlx shadcn@latest add @optics/ai-plan
Props
<Plan />
Name | Type | |
|---|---|---|
open | boolean | |
defaultOpen | boolean(default: false) | |
onOpenChange | ((open: boolean) => void) | |
isStreaming | boolean |
<PlanHeader />
Name | Type | |
|---|---|---|
icon | React.ReactNode | |
badge | React.ReactNode | |
render | React.ReactElement | |
nativeButton | boolean |
<PlanProgress />
Name | Type | |
|---|---|---|
completed | number | |
total | number | |
showLabel | boolean(default: true) | |
render | React.ReactElement | |
format | Intl.NumberFormatOptions | |
getAriaValueText | ((formattedValue: string, value: number) => string) | |
locale | Intl.LocalesArgument |
<PlanContent />
Name | Type | |
|---|---|---|
render | React.ReactElement | |
hiddenUntilFound | boolean | |
keepMounted | boolean | |
forceMount | boolean |
<PlanStep />
Name | Type | |
|---|---|---|
status | string(default: pending) | |
icon | React.ReactNode | |
description | React.ReactNode |