Reasoning
Slant / People & chat
A model’s thinking: open and shimmering while it thinks, folded away when done.
Demo
Usage
import { Reasoning } from '@tuttn/slant'
// Open, with the title shimmering "Thinking…", while the model thinks; folded
// under "Thought for 4 seconds" once thinking turns false.
<Reasoning thinking={streaming} duration={seconds}>{reasoningText}</Reasoning>
// A reader who opens or closes it mid-thought keeps it that way. Controlled,
// open wins, and the folding only reaches onOpenChange.
<Reasoning thinking={streaming} duration={seconds} open={open} onOpenChange={setOpen}>
{reasoningText}
</Reasoning>
// Your own title. It still shimmers while thinking.
<Reasoning thinking={streaming} title="Planning the migration">{plan}</Reasoning>Props
| Prop | Type | Default | Description |
|---|---|---|---|
thinking | boolean | false | While true, the title shimmers ("Thinking…") and the panel opens to show the reasoning as it streams in. When it turns false the panel folds itself away, unless the reader opened or closed it meanwhile, or `open` is controlled. |
duration | number | — | How long the model thought, in seconds, for the title once it is done ("Thought for 4 seconds"). |
title | ReactNode | messages.thinking, then messages.thoughtFor(duration) | Replaces the title. It shimmers while thinking. |
defaultOpen | boolean | thinking | Whether the panel starts open when uncontrolled. |
open | boolean | — | Whether the panel is open. Pass it to control the disclosure; leave it out and it keeps its own state. |
onOpenChange | (open: boolean) => void | — | Called with the requested state when the toggle is pressed. |
heading | 'h2' | 'h3' | 'h4' | 'div' | — | The element wrapping the toggle button, so it sits in the page's outline. |
disabled | boolean | — | Disables the toggle button: the panel stays as it is, open or closed, and the toggle leaves the tab order. |
toggleProps | Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'disabled' | 'aria-expanded' | 'aria-controls' | 'children'> | — | Extra attributes for the toggle button, such as `id`, `aria-describedby` or `aria-disabled`. With `aria-disabled` the toggle stays focusable but a press does nothing. Its `onClick` runs first and can call `preventDefault()` to keep the panel as it is. |
children | ReactNode | — | The panel's content. The panel sets a muted body text style, so pass plain text or `Text`. |
…rest | HTMLAttributes<HTMLDivElement> | — | The ref, className, style and other attributes go on the root div, which carries `data-thinking` while thinking. `heading`, `disabled` and `toggleProps` work as on Disclosure. |
Keyboard
| Tab | focuses the toggle |
| Enter / Space | opens or folds the reasoning |
Accessibility
- The toggle is a button inside a heading (
heading, an h3 by default), witharia-expandedandaria-controlson the panel, as Disclosure’s. - The title stays real text while it shimmers, so the button is named “Thinking…” and then “Thought for 4 seconds”. The sparkle before it is hidden from screen readers.
- When thinking ends it announces
messages.thoughtFor(duration)once, politely, through the root’s announcer. The reasoning itself is not announced as it streams, so a screen reader is not read every token; open the panel to read it. - It folds itself only for a reader who left it alone: open or close it mid-thought and it stays as you left it.
Motion and direction
The title’s sweep is Shimmer’s: under prefers-reduced-motion it rests as plain muted text, and the panel opens without Disclosure’s fade. The hairline beside the reasoning sits at the inline start, so under dir="rtl" it moves to the right and the sweep runs from the right.
Content
The panel sets smaller muted text for the reasoning, so pass plain text, or Text variant="hint", rather than body text.