BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/dedevs-ui/ai-reasoning

ai-reasoning

dedevs-ui/ai-reasoning
FreeComponent

AI reasoning visualization component

See it running

Open the demo on dedevs-ui

ui.dedevs.com/components/ai-reasoning
Open
This registry sends X-Frame-Options, so its page cannot be embedded here. The link is the same page the frame would have shown.

Install it

npx shadcn@latest add https://ui.dedevs.com/r/ai-reasoning.json

Source

packages/ai/reasoning.tsxui.dedevs.com/r/ai-reasoning.json
1'use client';
2
3import { useControllableState } from '@radix-ui/react-use-controllable-state';
4import {
5 Collapsible,
6 CollapsibleContent,
7 CollapsibleTrigger,
8} from '@repo/shadcn-ui/components/ui/collapsible';
9import { ChevronDownIcon } from 'lucide-react';
10import type { ComponentProps } from 'react';
11import { createContext, memo, useContext, useEffect, useState } from 'react';
12import { cn } from '@repo/shadcn-ui/lib/utils';
13import { AIResponse } from './response';
14
15type AIReasoningContextValue = {
16 isStreaming: boolean;
17 isOpen: boolean;
18 setIsOpen: (open: boolean) => void;
19 duration: number;
20};
21
22const AIReasoningContext = createContext<AIReasoningContextValue | null>(null);
23
24const useAIReasoning = () => {
25 const context = useContext(AIReasoningContext);
26 if (!context) {
27 throw new Error('AIReasoning components must be used within AIReasoning');
28 }
29 return context;
30};
31
32export type AIReasoningProps = ComponentProps<typeof Collapsible> & {
33 isStreaming?: boolean;
34 open?: boolean;
35 defaultOpen?: boolean;
36 onOpenChange?: (open: boolean) => void;
37 duration?: number;
38};
39
40export const AIReasoning = memo(
41 ({
42 className,
43 isStreaming = false,
44 open,
45 defaultOpen = false,
46 onOpenChange,
47 duration: durationProp,
48 children,
49 ...props
50 }: AIReasoningProps) => {
51 const [isOpen, setIsOpen] = useControllableState({
52 prop: open,
53 defaultProp: defaultOpen,
54 onChange: onOpenChange,
55 });
56 const [duration, setDuration] = useControllableState({
57 prop: durationProp,
58 defaultProp: 0,
59 });
60
61 const [hasAutoClosedRef, setHasAutoClosedRef] = useState(false);
62 const [startTime, setStartTime] = useState<number | null>(null);
63
64 // Track duration when streaming starts and ends
65 useEffect(() => {
66 if (isStreaming) {
67 if (startTime === null) {
68 setStartTime(Date.now());
69 }
70 } else if (startTime !== null) {
71 setDuration(Math.round((Date.now() - startTime) / 1000));
72 setStartTime(null);
73 }
74 }, [isStreaming, startTime, setDuration]);
75
76 // Auto-open when streaming starts, auto-close when streaming ends (once only)
77 useEffect(() => {
78 if (isStreaming && !isOpen) {
79 setIsOpen(true);
80 } else if (!isStreaming && isOpen && !defaultOpen && !hasAutoClosedRef) {
81 // Add a small delay before closing to allow user to see the content
82 const timer = setTimeout(() => {
83 setIsOpen(false);
84// … truncated

Files it writes

  • packages/ai/reasoning.tsx

Facts

Registry
dedevs-ui
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

Docs on dedevs-ui ui.dedevs.com DeDevsClub/dedevs-ui on GitHub Raw registry item This item as JSON

More from dedevs-ui

All 30 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
ai-branchai-branchdedevs-uiComponentsFreeno deps
ai-conversationai-conversationdedevs-uiComponentsFreeno deps
ai-inputai-inputdedevs-uiComponentsFreeno deps
ai-messageai-messagededevs-uiComponentsFreeno deps
ai-responseai-responsededevs-uiComponentsFreeno deps
ai-serverai-serverdedevs-uiComponentsFreeno deps
ai-simpleai-simplededevs-uiComponentsFreeno deps
ai-sourceai-sourcededevs-uiComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex