AI · 6 free pieces

SwiftUI AI chat components

The surfaces an AI feature needs: a streaming reply, a thinking state, prompt suggestion chips, the sources behind an answer and Siri-style orbs drawn in Metal.

All components

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.

Source Stack folds an answer's citations into one pill of site badges that opens into numbered source cards, the badges flying out of the stack into their cards. 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.

Ready to build something better?

85 pieces, one file each, yours to keep. Start with the library or see what the whole app looks like.