AI Elements Guide
Overview
Guide for integrating AI Elements into React/Next.js projects, composing chat and agent UIs, and auditing reasoning or plan presentation. Always target the latest AI Elements release and confirm API props from the official docs or the snapshot.
Workflow Decision Tree
- •New integration or missing AI Elements -> follow "Implement AI Elements in a project"
- •Build or redesign chat UI -> follow "Compose a chat UI"
- •Review chain-of-thought or reasoning -> follow "Review chain-of-thought or reasoning usage"
- •Only need props or links -> use references and the props snapshot, then verify against docs
Workflow: Implement AI Elements in a project
- •Identify stack: Next.js App Router vs Pages, React version, Tailwind or ShadCN usage.
- •Confirm AI SDK and AI Elements versions: check docs in
references/ai-elements-docs.md. - •Install dependencies using the official usage page and record versions in notes.
- •Decide data flow: hook or transport used for streaming and message state.
- •Add AI Elements components progressively and verify CSS and layout.
- •Validate with a minimal example and expand to the full UI.
Workflow: Compose a chat UI
- •Pick core components: conversation container, message list, prompt input, attachments.
- •Add optional UX: sources, inline citations, suggestions, model selector, shimmer or loader.
- •Add reasoning views only if required and allowed by product needs.
- •Use example compositions in
references/examples.mdand docs. - •For each component used, include API props in output (pull from doc page).
Workflow: Review chain-of-thought or reasoning usage
- •Find where chain-of-thought or reasoning components render in the UI.
- •Confirm the content shown is intended for end users.
- •Ensure fallback behavior when reasoning is unavailable or disabled.
- •Verify consistency across streaming and non-streaming paths.
- •Document findings and recommended changes.
Workflow: Troubleshoot
- •Check
/elements/troubleshootingfor known issues. - •Validate CSS and layout isolation (Tailwind or ShadCN).
- •Verify client and server boundaries in Next.js.
- •Confirm AI SDK streaming and message state are wired correctly.
Workflow: Refresh API props snapshot
- •Run
python3 scripts/update_api_props.py(requires network access). - •Review
references/api-props.mdfor failures and re-run if needed. - •If props differ from docs, note the delta in your response.
References
- •
references/ai-elements-docs.mdfor the canonical link index (update if new docs appear). - •
references/component-index.mdfor component map and doc links. - •
references/examples.mdfor example compositions and links. - •
references/api-props.mdfor the props snapshot (regenerate if docs change). - •
scripts/update_api_props.pyto refresh the snapshot.
Output Requirements
When responding to a user request:
- •Provide component list and doc links used.
- •Include key API props for each component from the docs.
- •Provide a short implementation workflow and a concise example.
- •Call out any version assumptions and gaps.
- •If props differ from the snapshot, note the delta and update
references/api-props.md.