A message component that displays AI thinking process with collapsible content and a status indicator.
- Expandable/Collapsible: Click the button to toggle content visibility
- Status Indicator: Shows loader animation when status is "thinking"
- Copy Action: Optional copy button for completed thoughts with custom or default logic
- Flexible Content: Supports single string or array of content strings
- Markdown Support: Content is rendered as Markdown while preserving the gray text color
- Backward Compatible: Supports both custom copy handlers and automatic copy functionality
import {ThinkingMessage} from '@gravity-ui/aikit';
<ThinkingMessage
content={[
'Analyzing your request and considering different approaches.',
'Evaluating the best solution based on your requirements.',
]}
status="thinking"
defaultExpanded={true}
showStatusIndicator={true}
/>;<ThinkingMessage
content={['First thinking block', 'Second thinking block']}
status="thought"
enabledCopy={true} // Enables default copy logic
/>When user clicks the copy button, the content will be copied as:
First thinking block
Second thinking block
<ThinkingMessage
content="Processing your request..."
status="thought"
onCopyClick={() => {
// Custom copy logic
navigator.clipboard.writeText('Custom text');
showNotification('Copied!');
}}
/><ThinkingMessage content="Processing your request..." status="thinking" />| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
content |
string | string[] |
✓ | - | Thinking content as a string or array of strings |
status |
'thinking' | 'thought' |
✓ | - | Current thinking status |
defaultExpanded |
boolean |
- | true |
Initial expanded state |
showStatusIndicator |
boolean |
- | true |
Whether to show loader when status is "thinking" |
format |
'plain' | 'markdown' |
- | 'plain' |
How thinking content strings are rendered |
transformOptions |
OptionsType |
- | - | Options from @diplodoc/transform; Used when format is 'markdown' |
onCopyClick |
() => void |
- | - | Custom copy handler. Takes priority over enabledCopy |
enabledCopy |
boolean |
- | false |
Enable default copy functionality. Content is copied as-is (string) or joined with \n\n (array) |
className |
string |
- | - | Additional CSS class name |
qa |
string |
- | - | Data QA attribute for testing |
style |
React.CSSProperties |
- | - | Inline styles |
type ThinkingMessageData = {
content: string | string[];
status: 'thinking' | 'thought';
};- thinking: Active thinking process - shows loader animation and "Thinking" button label
- thought: Completed thought - shows copy button and "Thought" button label
- Click the button to toggle content visibility
- Button label changes based on status: "Thinking" or "Thought"
- Button icon shows chevron down (collapsed) or up (expanded)
- Content is expanded by default (
defaultExpanded={true})
When status is 'thinking' and showStatusIndicator is true, a loader animation is displayed next to the button, indicating the AI is actively processing.
The copy button appears when status is 'thought' (completed) and either onCopyClick or enabledCopy is provided.
Priority:
- If
onCopyClickis provided, it will be used (custom logic) - If
enabledCopy={true}, default copy logic will be used - If neither is provided, no copy button is shown
Default Copy Logic:
- For string content: copies the string as-is
- For array content: joins items with double newline (
\n\n)
This matches the visual display format where each array item appears as a separate paragraph.
The component uses the following CSS variables for styling, which can be customized via inline styles or CSS:
| Variable | Default Usage | Description |
|---|---|---|
--g-spacing-1 |
4px |
Vertical padding (top and bottom) |
--g-spacing-2 |
8px |
Gap between buttons and content |
--g-spacing-4 |
16px |
Left padding |
--g-spacing-6 |
24px |
Gap between content items |
| Variable | Description |
|---|---|
--g-color-line-generic |
Left border color |
--g-color-text-complementary |
Content text color |
| Variable | Description |
|---|---|
--g-text-body-1-font-size |
Content font size |
--g-text-body-font-weight |
Content font weight |
--g-text-body-1-line-height |
Content line height |