Docs
AI

Thinking State

The assistant-is-working placeholder: a glass header with a breathing mark and elapsed seconds over dots, bars or a sheen.

$npx swiftpieces add ThinkingState
Free · MIT + Commons ClauseiOS 17.0+Liquid Glassloadingthinkingsheenplaceholderaielapsed
Type
ThinkingState
Files
ThinkingState.swift
Depends on
Nothing (Apple frameworks only)
Version
2.2.0
In a full screen · SwiftPieces ProAgent TaskAn agent task screen with a live timeline of tool calls, durations and expandable results.

Placeholder for a reply that has not started. Every presentation mirrors the StreamingReply layout (mark and label, then content) so it resolves into the real message without a layout jump.

Notes

  • Every presentation shares the StreamingReply layout: a liquid glass header pill (breathing ink mark, name and a THINKING · 3S elapsed label that counts up) and then content sized to a body line, so swapping ThinkingState for a StreamingReply lands on the same pill and does not shift anything. Set style.showsHeader = false for content only.
  • .dots rises three block-colored dots (tangerine, sky, lilac by default), .sheen sweeps a band across reply-shaped bars, and .text(label) sweeps the band through the label's glyphs.
  • One TimelineView drives the mark's breath, the dots and the sheen, so they stay phase-locked. It starts when the placeholder appears: the first pass enters from the leading edge and the dots rise from rest. duration sets the period of one pass.
  • Each pass eases the band across over the first 80% of duration, then rests just clear of the view before the next. The band slides whole, so it keeps its width as it enters and leaves. The mark draws in and turns on the same beat and is back to full size and upright between passes, which is the StreamingReply mark's pose. Each dot eases out of rest and back, as in StreamingReply.
  • Each second the count morphs: the digits it shares with the last one hold still and the new ones blur in, in tabular figures, so the pill only widens (with a little give) when the count gains a digit. THINKING · holds still.
  • Pass tint to use one color for the dots, mark and sheen.
  • .thinkingState(_:tint:) masks a bright sweep to the view's own alpha, so it follows capsules, glyphs and text with no clipping setup. It runs the same paced 2.2-second pass, starting from the leading edge each time isActive turns true, and fades in and out with isActive. On a glass pill, put it on the label inside the glass, as the example does, so the sweep runs through the words and the glass stays clear.
  • Style (ThinkingState.Style): dots, bar, sheen, mark, markInk, ink, text, muted, assistantName, showsHeader.
  • Every string is semibold. Under Reduce Motion nothing moves, but the placeholder still shows it is working: the band becomes an even glow that brightens and fades in place on the same beat (over the bars, through the label's glyphs, and in the modifier), the dots hold still and ripple their opacity, the mark rests full size and upright, and the elapsed seconds crossfade. Reduce Transparency makes the pill solid.
  • Need a live timeline of tool calls with durations and results? That is the Tool Execution Card screen in SwiftPieces Pro.

Usage

ThinkingStateExample().preferredColorScheme(.light)

Parameters

ParameterDescription
presentation.dots, .sheen (reply-shaped bars), or .text(label).
tintOptional single color for the dots, mark and sheen. nil uses the house blocks for the dots and a neutral sheen.
lineCountNumber of placeholder bars in the .sheen presentation.
durationSeconds per sheen sweep; the dots and mark breathe on the same clock.
styleColors, the assistant name and whether the header with elapsed seconds shows. Defaults to the house palette.

Install

Pick one. Run it from the folder that contains your .xcodeproj and the files land inside your app.

Terminal

$npx swiftpieces add ThinkingState

Or ask your coding agent · Claude Code, Cursor or Xcode, once the MCP server is connected

>Add the SwiftPieces "Thinking State" piece to my app

Or copy the source above into your app.

New to SwiftUI?If you know React, CSS or Tailwind, SwiftUI is easier to pick up than it looks.Try real app patterns first

Building a whole app? See SwiftPieces Pro →

All ai →

Build it yourself: SwiftUI loading states guide · SwiftUI animations guide

On this page

SwiftPiecesPro

Build the whole app with one library.

Production-ready screens, whole flows, complete app templates, a Build Kit your agent follows and Pro remixing.

54 screens · 46 patterns · 48 flows · 12 templates · 31 Build Kit skills

Explore Pro