UI Primitives for building AI apps in React Native.
[!WARNING]
aix is currently in alpha preview. The API is likely to change.
Features
Start a chat scrolled to end on the first frame
Animate scrolling to new messages when they send
Float messages to the top of the screen with automated "blank size" handling
Animate message content as it streams
Keyboard handling out-of-the-box with no external dependencies
Support for absolute-positioned composers
Detect "is scrolled near end" for ScrollToEnd buttons
To learn about the motivation behind AIX, you can read our blog post on
How we built the v0 iOS app.
AIX is an opinionated, feature-complete, and extensible way to implement every
single feature mentioned in that blog post.
When building AIX, we started by copying the code from v0 into a separate
repository. However, as we worked to make it flexible for use cases outside of
our own app, we decided to rewrite it from scratch in native code. What you see
here is a Nitro Module which handles all business logic in UIKit. We plan on
adding support for Android as well and welcome contributions.
Installation
npm i aix react-native-nitro-modules
Next, rebuild your native app. For Expo users, run npx expo prebuild and
rebuild.
To add a floating composer which lets content scroll under it, you can use the
AixFooter. Pair it with Aix.scrollOnFooterSizeUpdate to ensure content
scrolls under the footer when it changes size.
When sending a message, you will likely want to scroll to it after it gets added
to the list. Use the scrollToIndex prop to declaratively trigger an animated
scroll, and onDidScrollToIndex to reset the state when the scroll completes.
The index you pass should correspond to the newest message in the list. For AI
chats, this is typically the next assistant message index. Use a nullish value (null | undefined) to indicate
no scroll target.
Control the behavior of scrolling when the footer size changes. By default, changing the height of the footer will shift content up in the scroll view.
scrollEndReachedThreshold
number
max(blankSize, 200)
The number of pixels from the bottom of the scroll view to the end of the content that is considered "near the end". Used by onScrolledNearEndChange and to determine if content should shift up when keyboard opens.
onScrolledNearEndChange
(isNearEnd: boolean) => void
-
Callback fired when the scroll position transitions between "near end" and "not near end" states. Reactive to user scrolling, content size changes, parent size changes, and keyboard height changes. Uses to determine the threshold.
Ref Methods
Access these methods via useAixRef():
const aix = useAixRef()// Scroll to the end of the contentaix.current?.scrollToEnd(animated)
Method
Parameters
Description
scrollToEnd
animated?: boolean
Scrolls to the end of the content.
Note: For scrolling to a specific message index, prefer using the
declarative scrollToIndex prop instead of imperative methods.
AixCell
A wrapper component for each message in the list. It communicates cell position
and dimensions to the parent Aix component.
Props
Prop
Type
Required
Description
index
number
Yes
The index of this cell in the message list.
isLast
boolean
Yes
Whether this cell is the last item in the list. Used for scroll positioning and animations.
AixFooter
A footer component for floating composers that allows content to scroll
underneath it. The footer's height is automatically tracked for proper scroll
offset calculations.
Props
Accepts all standard React Native View props.
Important Notes
Do not apply vertical padding (padding, paddingBottom) directly to
AixFooter. Apply padding to a child view instead.
Position the footer absolutely at the bottom of the Aix container:
Additional content insets applied when keyboard is open or closed. Shape: { top?: { whenKeyboardOpen, whenKeyboardClosed }, bottom?: { whenKeyboardOpen, whenKeyboardClosed } }
additionalScrollIndicatorInsets
object
-
Additional insets for the scroll indicator, added to existing safe area insets. Applied to verticalScrollIndicatorInsets on iOS.
mainScrollViewID
string
-
The nativeID of the scroll view to use. If provided, will search for a scroll view with this accessibilityIdentifier.
penultimateCellIndex
number
-
The index of the second-to-last message (typically the last user message in AI chat apps). Used to determine which message will be scrolled into view. Useful when you have custom message types like timestamps in your list.
scrollToIndex
number
-
When set, triggers an animated scroll to this cell index. Use a nullish value (null or undefined) to indicate no scroll target. After the scroll completes, onDidScrollToIndex is called. Reset after receiving the callback.
onDidScrollToIndex
() => void
-
Called when the animated scroll to scrollToIndex completes. Use this to clear the scrollToIndex state.