appCN
← All components

Reasoning Trace

AI
new

A collapsible chain-of-thought panel. Shimmers while thinking, then collapses itself the instant the answer lands.

Preview

Scan with Expo Go to run it live

Install Expo Goon Android or iPhone, scan, and the entire appCN gallery loads — real native motion & gestures, not a web shim.

Open in Expo Go Play Store — coming soon
https://expo.dev/preview/update?message=v1.0.0+initial&updateRuntimeVersion=1.0.0&createdAt=2026-05-28T20%3A07%3A21.247Z&slug=exp&projectId=a2d02caa-be26-436a-acd6-f3007862ba0a&group=3ca7e750-9506-4146-8394-1a16c3a917a8

Install

npx @app-cn/cli@latest add reasoning-trace

Recommended. Configures NativeWind + Reanimated and registers @app-cn on first run.

Anatomy

An expandable card with a pressable header (label + animated chevron) and an animated body. The body's height is driven by a measured layout value so the panel can grow with streaming reasoning without jumping. While thinking, a soft light streak sweeps across the body — the universal signal for 'work in progress'.

The delight detail

When `thinking` flips false, the panel auto-collapses its own height (unless the user manually toggled it open) — the trace gets out of the way the moment the answer is ready, so the user doesn't have to do it themselves.

Props

NameTypeDefaultDescription
reasoning*stringThe chain-of-thought text. Can stream in while `thinking` is true.
thinkingbooleanfalseWhether the model is still reasoning. When it flips false, the panel auto-collapses (unless the user toggled it).
labelstringHeader label override. Defaults to "Thinking…" / "Thought for Ns".
expandedbooleanControlled expanded state. Omit to use uncontrolled mode.
defaultExpandedbooleanfalseInitial expanded state in uncontrolled mode. The panel auto-expands while `thinking` regardless.
onExpandedChange(expanded: boolean) => voidFires when the panel opens or closes (user tap or auto-collapse).
autoCollapsebooleantrueWhen true, the panel collapses itself the instant `thinking` flips from true to false. The user can override by tapping the header.
classNamestringExtra NativeWind classes merged onto the outer card.

Examples

Streaming with auto-collapse

Hand the panel reasoning as it streams. When `thinking` flips false, it collapses on its own.

const [thinking, setThinking] = React.useState(true);
const [reasoning, setReasoning] = React.useState("");

React.useEffect(() => {
  const FULL = "The user wants a concise answer. Lead with the recommendation…";
  let i = 0;
  const id = setInterval(() => {
    i += 3;
    setReasoning(FULL.slice(0, i));
    if (i >= FULL.length) {
      clearInterval(id);
      setTimeout(() => setThinking(false), 700);
    }
  }, 28);
  return () => clearInterval(id);
}, []);

return <ReasoningTrace reasoning={reasoning} thinking={thinking} />;

Manually controlled

Drive expanded yourself if you need to coordinate with surrounding UI.

const [expanded, setExpanded] = React.useState(false);
return (
  <ReasoningTrace
    reasoning="I considered three options and went with the simplest…"
    expanded={expanded}
    onExpandedChange={setExpanded}
  />
);

Accessibility

  • The header is a button with `accessibilityState.expanded` so VoiceOver announces the open/closed state.
  • `accessibilityLabel` mirrors the visible header text (`Thinking…` / `Thought for Ns`).
  • Tapping the header fires `haptic.selection()` — a crisp detent tick that grounds the toggle.
  • Honors `useReducedMotion()` — the height animation, shimmer, and chevron rotation all short-circuit to instant.