# AuiIf URL: /docs/api-reference/primitives/assistant-if Conditional rendering component based on thread, message, or composer state. Conditionally render children based on assistant state. Anatomy \[#anatomy] ```tsx import { AuiIf } from "@assistant-ui/react"; s.thread.isEmpty}> ``` Overview \[#overview] `AuiIf` is a generic conditional rendering component that provides access to the full assistant state. It replaces the deprecated `ThreadPrimitive.If`, `MessagePrimitive.If`, and `ComposerPrimitive.If` components with a single, flexible API. API Reference \[#api-reference] AssistantState \[#assistantstate] The condition function receives an `AssistantState` object with the following properties: Examples \[#examples] Thread State Conditions \[#thread-state-conditions] ```tsx // Show welcome screen when thread is empty s.thread.isEmpty}> // Show loading indicator while running s.thread.isRunning}> // Conditional send/cancel button !s.thread.isRunning}> Send s.thread.isRunning}> Cancel ``` Message State Conditions \[#message-state-conditions] ```tsx // Show avatar only for assistant messages s.message.role === "assistant"}> // Show disclaimer on last message s.message.isLast}> // Toggle copy icon based on copied state !s.message.isCopied}> s.message.isCopied}> // Show speak/stop button based on speech state s.message.speech == null}> s.message.speech != null}> ``` Composer State Conditions \[#composer-state-conditions] ```tsx // Show placeholder when composer is empty s.composer.isEmpty}> // Show attachment preview when editing s.composer.isEditing}> ``` Complex Conditions \[#complex-conditions] ```tsx // Combine multiple conditions !s.thread.isRunning && s.message.role === "assistant" }> // Custom logic s.thread.messages.length > 0 && !s.thread.isRunning }> ``` Type Export \[#type-export] You can import the `AuiIf.Condition` type for typing your condition functions: ```tsx import { AuiIf } from "@assistant-ui/react"; const isThreadEmpty: AuiIf.Condition = (s) => s.thread.isEmpty; ``` Migration from Deprecated Components \[#migration-from-deprecated-components] `ThreadPrimitive.If`, `MessagePrimitive.If`, and `ComposerPrimitive.If` are deprecated. Use `AuiIf` instead. | Before | After | | -------------------------------------- | ----------------------------------------------------------- | | `` | ` s.thread.isEmpty}>` | | `` | ` s.thread.isRunning}>` | | `` | ` !s.thread.isRunning}>` | | `` | ` s.message.role === "user"}>` | | `` | ` s.message.role === "assistant"}>` | | `` | ` s.message.isCopied}>` | | `` | ` s.message.speech != null}>` | | `` | ` s.message.isLast}>` | | `` | ` s.composer.isEditing}>` |