Floating assistant modal primitives for building support chat, copilot, and embedded assistant experiences.
For examples and usage patterns, see AssistantModal.
Anatomy
import { AssistantModalPrimitive } from "@assistant-ui/react";
const AssistantModal = () => (
<AssistantModalPrimitive.Root>
<AssistantModalPrimitive.Trigger>
<FloatingAssistantButton />
</AssistantModalPrimitive.Trigger>
<AssistantModalPrimitive.Content>
<Thread />
</AssistantModalPrimitive.Content>
</AssistantModalPrimitive.Root>
);API Reference
Root
AssistantModalPrimitiveRootPropsopen?: booleandefaultOpen?: booleanonOpenChange?: (open: boolean) => voidmodal?: booleanunstable_openOnRunStartunstable?: boolean
Trigger
This primitive renders a <button> element unless asChild is set.
AssistantModalPrimitiveTriggerPropsasChild: boolean= falseChange the default rendered element for the one passed as a child, merging their props and behavior.
Read the Composition guide for more details.
| Data attribute | Values |
|---|---|
[data-state] | "open" | "closed" |
Content
This primitive renders a <div> element unless asChild is set.
AssistantModalPrimitiveContentPropsasChild: boolean= falseChange the default rendered element for the one passed as a child, merging their props and behavior.
Read the Composition guide for more details.onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus']Event handler called when auto-focusing on open. Can be prevented.
side?: SidesideOffset?: numberalign?: AlignalignOffset?: numberarrowPadding?: numberavoidCollisions?: booleancollisionBoundary?: Boundary | Boundary[]collisionPadding?: number | Partial<Record<Side, number>>sticky?: 'partial' | 'always'hideWhenDetached?: booleanupdatePositionStrategy?: 'optimized' | 'always'onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus']Event handler called when auto-focusing on close. Can be prevented.
onEscapeKeyDown?: (event: KeyboardEvent) => voidEvent handler called when the escape key is down. Can be prevented.
onPointerDownOutside?: (event: PointerDownOutsideEvent) => voidEvent handler called when the a `pointerdown` event happens outside of the `DismissableLayer`. Can be prevented.
onFocusOutside?: (event: FocusOutsideEvent) => voidEvent handler called when the focus moves outside of the `DismissableLayer`. Can be prevented.
onInteractOutside?: (event: PointerDownOutsideEvent | FocusOutsideEvent) => voidEvent handler called when an interaction happens outside the `DismissableLayer`. Specifically, when a `pointerdown` event happens outside or focus moves outside of it. Can be prevented.
forceMount?: trueUsed to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
portalProps?: ComponentPropsWithoutRef<typeof PopoverPrimitive.Portal>container?: PortalProps['container']Specify a container element to portal the content into.
forceMount?: trueUsed to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
dissmissOnInteractOutside?: boolean
Anchor
This primitive renders a <div> element unless asChild is set.
AssistantModalPrimitiveAnchorPropsasChild: boolean= falseChange the default rendered element for the one passed as a child, merging their props and behavior.
Read the Composition guide for more details.virtualRef?: React.RefObject<Measurable>