SwiftUI AI chat components
The surfaces an AI feature needs: a streaming reply, a thinking state, prompt suggestion chips, a code block and Siri-style orbs drawn in Metal.
About these pieces
One self-contained Swift file each, Apple frameworks only, from iOS 17.
Streaming Reply is the reply surface: text arrives token by token with a per-word fade and a cursor, inline code sits on blocks, and a long press lifts the message to copy or regenerate. Thinking State is the working placeholder, laid out like the reply it becomes, with an elapsed-seconds label. Prompt Chips is a snapping row of suggestions where the chosen chip morphs into the composer.
Code Block renders code for chat replies with Swift syntax colors, collapse and expand, a wrap toggle and a copy pill, plus a streaming mode. Assistant Orb and Thought Orb are dark glass balls with a Siri-style voice wave inside, drawn by a Metal shader, whose palettes crossfade with the kind of work in progress.
Learn the technique: SwiftUI loading states guide, SwiftUI animations guide.
Questions
How the pieces work, and how to build the same thing yourself. Every piece's page has its full notes.
How do I stream text in SwiftUI like ChatGPT?
Append tokens to a string in @State as they arrive from an AsyncSequence, and animate each new word in. Streaming Reply does this with a per-word fade and a block cursor, and exposes copy and regenerate.
Do these pieces include an AI model or API client?
No. They are the interface only. Connect them to any model or API: Apple's Foundation Models framework, a server you run, or a hosted provider.
Keep browsing
Nearby collections, then every category in the library.
- FeedbackReactions, ratings, status morphs, skeletons and outcomes.5
- TextType that reveals, expands and renders as glass.3
- BackgroundsQuiet atmospheres: a Metal silk shader and a touch-reactive dot grid.2
- Liquid GlassCorrect iOS 26 Liquid Glass with Material fallbacks.3
- Buttons and controlsButtons and dials with press depth, hold, drag and outcome states.5
- Inputs and formsTracks, steppers, rails and fields built for the thumb.9
- CardsCards with depth, motion, parallax and gesture-driven stacks.4
- ListsRows and carousels with swipe, depth and completion physics.5
- NavigationFloating docks, tracking tabs and stretchy headers.3
- SheetsToasts, confirmations and permission moments.3
- MotionGesture modifiers with real physics.1
- Data and chartsScrubbable charts, rings, live stats and odometers.4
- MediaPhoto viewing and story playback.2
- AnimationsSprings, gesture physics, transitions and morphs, across every category.16
- HapticsPieces that tick, tap and confirm at the moment that matters.19
Ready to build something better?
55 pieces, one file each, yours to keep. Start with the library or see what the whole app looks like.