Reasoning

A collapsible component for showing AI reasoning, explanations, or logic. You can control it manually or let it auto-close when the stream ends. Markdown is supported.

Examples

Basic Usage

The most basic implementation of the Reasoning component with auto-close functionality when streaming ends.

With Markdown

Show rich formatting with markdown support for better structured reasoning content.

Installation

Copy and paste the following code into your project.

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

Component API

Reasoning

PropTypeDefaultDescription
childrenSnippet-The content of the component
classNamestring-Additional CSS classes
openboolean-Control the open state (makes component controlled)
onOpenChange(open: boolean) => void-Callback when open state changes
isStreamingboolean-When false, automatically closes the reasoning (auto-close)

ReasoningTrigger

PropTypeDefaultDescription
childrenSnippet-The content of the trigger
classNamestring-Additional CSS classes
...propsHTMLAttributes<HTMLButtonElement>-Additional HTML button props

ReasoningContent

PropTypeDefaultDescription
childrenSnippet-The content to be displayed
classNamestring-Additional CSS classes
contentClassNamestring-Additional CSS classes for the content
markdownbooleanfalseEnable markdown rendering for the content
...propsHTMLAttributes<HTMLDivElement>-Additional HTML div props