Chain of Thought

A collapsible component that visualizes AI reasoning steps with support for search results, images, and step-by-step progress indicators.

The ChainOfThought component provides a visual representation of an AI's reasoning process, showing step-by-step thinking with support for search results, images, and progress indicators. It helps users understand how AI arrives at conclusions.

Install using CLI

AI Elements Vue
shadcn-vue CLI
npx ai-elements-vue@latest add chain-of-thought

Install Manually

Copy and paste the following files into the same folder.

ChainOfThought.vue
ChainOfThoughtHeader.vue
ChainOfThoughtStep.vue
ChainOfThoughtSearchResults.vue
ChainOfThoughtSearchResult.vue
ChainOfThoughtContent.vue
ChainOfThoughtImage.vue
context.ts
index.ts
<script setup lang="ts">
import type { HTMLAttributes, Ref } from 'vue'
import { cn } from '@repo/shadcn-vue/lib/utils'
import { useVModel } from '@vueuse/core'
import { provide } from 'vue'
import { ChainOfThoughtContextKey } from './context'

interface ChainOfThoughtProps {
  modelValue?: boolean
  defaultOpen?: boolean
  class?: HTMLAttributes['class']
}

const props = withDefaults(
  defineProps<ChainOfThoughtProps>(),
  {
    defaultOpen: false,
    modelValue: undefined,
  },
)

const emit = defineEmits<{
  (e: 'update:modelValue', value: boolean): void
}>()

const isOpen = useVModel(props, 'modelValue', emit, {
  defaultValue: props.defaultOpen,
  passive: true,
})

provide(ChainOfThoughtContextKey, isOpen as Ref<boolean>)
</script>

<template>
  <div
    :class="cn('not-prose max-w-prose space-y-4', props.class)"
    v-bind="$attrs"
  >
    <slot />
  </div>
</template>

Features

  • Collapsible interface with smooth animations powered by Reka UI
  • Step-by-step visualization of AI reasoning process
  • Support for different step statuses (complete, active, pending)
  • Built-in search results display with badge styling
  • Image support with captions for visual content
  • Custom icons for different step types
  • Context-aware components using Inject/Provide API
  • Fully typed with TypeScript
  • Accessible with keyboard navigation support
  • Responsive design that adapts to different screen sizes
  • Smooth fade and slide animations for content transitions
  • Composable architecture for flexible customization

Props

<ChainOfThought />

defaultOpenboolean
Whether the chain of thought is open by default.
classstring
''
Additional CSS classes to apply to the component.

<ChainOfThoughtHeader />

classstring
''
Additional CSS classes to apply to the component.

<ChainOfThoughtStep />

labelstring
The main text label for the step.
descriptionstring
Optional description text shown below the label.
status'complete' | 'active' | 'pending'
'complete'
Visual status of the step. Defaults to "complete".
classstring
''
Additional CSS classes to apply to the component.

<ChainOfThoughtSearchResults />

classstring
''
Additional CSS classes to apply to the component.

<ChainOfThoughtSearchResult />

classstring
''
Additional CSS classes to apply to the component.

<ChainOfThoughtContent />

classstring
''
Additional CSS classes to apply to the component.

<ChainOfThoughtImage />

captionstring
Optional caption text displayed below the image.
classstring
''
Additional CSS classes to apply to the component.