Silhouette
Silhouette draws a skeleton of exactly what is about to load in a SwiftUI app. Your view is laid out out of sight with sample data and traced: a bar for each line of text as it wraps, a block for each image, control and painted shape. When the data arrives it takes the skeleton's place, and nothing on the page moves.
Getting started
Install
In Xcode, choose File → Add Package Dependencies…, paste the repository URL and add the Silhouette library to your app target. In a package, add it to Package.swift:
dependencies: [
.package(
url: "https://github.com/terramind-org/silhouette.git",
from: "0.1.0"
),
],
targets: [
.target(name: "App", dependencies: [
.product(name: "Silhouette", package: "silhouette"),
]),
]
Silhouette needs iOS 17, macOS 14, tvOS 17, watchOS 10 or visionOS 1, and Swift 6 tools (Xcode 16 or later). See Platform support for what changes on older systems.
The 30-second version
Give your model a sample with typical lengths, then wrap the view that shows it. While user is nil, the card is built from the sample, traced, and shown as a skeleton.
import Silhouette
struct User: Codable {
var name: String
var role: String
var bio: String
static let sample = User(
name: "Ada Lovelace",
role: "Analyst",
bio: "Wrote the first published program, for a machine that was never built."
)
}
struct ProfileScreen: View {
@State private var user: User?
var body: some View {
Skeleton(user, sample: .sample) { user in
ProfileCard(user: user)
}
.task { user = try? await api.user() }
}
}
That's it. Every skeleton already follows light and dark mode, Dynamic Type, Reduce Motion and VoiceOver. To change how they look or arrive for the whole app, set a theme and a reveal once near the root:
WindowGroup {
ContentView()
.skeletonTheme { $0.radius = .pill }
.skeletonReveal(.smart) // the default
}
For coding agents
A skill teaches a coding agent to adopt Silhouette well: which API to pick, writing samples, hints, lists, accessibility, testing and a checklist to verify with the debug overlay. Save skill.md as SKILL.md in a silhouette folder in your agent's skills directory (for Claude Code, .claude/skills/silhouette/). llms.txt lists these docs for tools that read the web.
Skeletons
From your view and a sample
The skeleton is your own view. Pass the data, which is nil while it loads, and a sample of it. While the data is missing, your content closure is built from the sample, laid out invisibly and traced in its place. There is no second, hand-made skeleton to keep in step with the real one.
Skeleton(user, sample: .sample) { user in
ProfileCard(user: user)
}
The sample is never shown as content: people only ever see it as a skeleton, and the closure only appears on screen with real data. Give the sample typical lengths, a name of a usual length and a bio that wraps like a real one, because the skeleton takes exactly the space the sample does.
If you leave the sample out, debug builds log one to paste the first time real data arrives: your type's shape and lengths with every value replaced, so it's safe to commit.
The closest data
A skeleton is drawn from the closest data Silhouette has, in this order: the data already on screen, the data this skeleton last showed in this launch, your sample, then a shape remembered from an earlier launch. The sample comes first because remembered text keeps its letters' widths only roughly, and near the end of a line that can change where it wraps. With none of those, it draws three placeholder lines and logs a warning.
Empty and failed loads
Show something else once the data has arrived empty, or when loading failed. Chain these straight after the Skeleton, before any other modifier.
Skeleton(messages, sample: Message.samples) { messages in
Inbox(messages: messages)
}
.empty(messages?.isEmpty == true) {
ContentUnavailableView("No messages yet", systemImage: "tray")
}
.failure(loadError) { error in
RetryBanner(error: error)
}
Loading over data
Pass isLoading: true to show the skeleton even though you have data, for example while a refetch replaces it. The skeleton is drawn from what's on screen, so it's exact.
Skeleton(model.user, sample: .sample, isLoading: model.isRefreshing) {
ProfileCard(user: $0)
}
Any view with a flag
When a view doesn't fit the one-value shape, build it however you like and say when it's loading. The view is traced as it is, so give missing values a stand-in of typical length.
VStack(alignment: .leading, spacing: 6) {
Text(user?.name ?? "Placeholder name")
.font(.title2.bold())
Text(user?.bio ?? String(repeating: "Placeholder text ", count: 6))
}
.skeleton(isLoading: user == nil, label: Text("Loading profile"))
Regions nest. Put the modifier on just the part that loads for partial loading: a header can be ready while the list below it still shimmers. An inner region starts its own loading once the region around it has revealed.
Prefer Skeleton(data, sample:) when you can. Its content only ever receives real data, and it remembers shapes by id. Use .skeleton(isLoading:) for views assembled from several sources, or ones you can't restructure.
Your own skeleton
Some views don't trace well: a chart, a map, a cluster of tiny icons. Draw their skeleton yourself. Build it from SkeletonBox or any shape, and it joins the shared shimmer, follows the theme and quiets down under Reduce Motion like every traced skeleton.
SkeletonBox
One placeholder shape. By default it is 60% of the width on offer and one line of body text tall, with the theme's radius.
SkeletonBox() // 60% wide, one line tall
SkeletonBox(width: 40, height: 40, radius: .pill) // a round avatar
SkeletonBox(width: .fraction(1), height: .em(4), radius: .points(12))
| SkeletonLength | Meaning |
|---|---|
.points(_:) | A fixed size. A plain number literal means points. |
.fraction(_:) | A share of the width or height on offer, from 0 to 1. |
.em(_:) | A multiple of the body font's size, so it grows with Dynamic Type. |
skeletonShape
Replace one view's traced skeleton with your own, drawn in that view's frame:
Avatar(user: user)
.skeletonShape { Circle() }
WeeklyChart(days: days)
.skeletonShape {
HStack(alignment: .bottom, spacing: 6) {
ForEach([0.4, 0.7, 0.5, 0.9, 0.6, 0.8, 0.3], id: \.self) { height in
SkeletonBox(width: .fraction(1), height: .fraction(height), radius: .points(4))
}
}
}
placeholder
Replace a whole Skeleton's traced shape. The region still takes its size from your content laid out from the sample, so keep passing one; the placeholder is drawn in that frame.
Skeleton(forecast, sample: .sample) { WeatherMap(forecast: $0) }
.placeholder {
SkeletonBox(width: .fraction(1), height: .fraction(1), radius: .points(16))
}
Hints
Only what loads, loads: bundled pictures, labels and fixed values show as they are while the data arrives. Skeleton finds them on its own by also laying the view out from a scrambled copy of the sample: anything that looks the same both ways shows from the first frame. Mark the rest with .skeletonKeep(). What shows early stays put through the reveal too: entrances such as .zoom or .unveil move only what arrives.
Tracing gets most views right. Where it doesn't, mark the view.
| Hint | Use it for |
|---|---|
.skeletonBlock(cornerRadius:) | Things that trace into noise, such as a chart, a map, a video or a row of tiny glyphs. Draws one block filling the frame. |
.skeletonIgnored() | Decoration that shouldn't shimmer, such as a "New" badge or a divider, and container backgrounds. The view still takes its space. |
.skeletonKeep() | Something fixed that never waits for data, such as a label or a bundled picture, where Skeleton can't tell on its own (with .skeleton(isLoading:)). It shows as it is and isn't part of the reveal. |
.skeletonShape { } | Anything that needs a specific outline, such as a round avatar or a chart's bars. See Your own skeleton. |
Map(position: $position).skeletonBlock(cornerRadius: 12)
Text("New").skeletonIgnored()
Avatar(user: user).skeletonShape { Circle() }
Containers
A surface in or near the page's own colour, such as a white card in light mode or a black one in dark, and dark mode's raised greys up to about 11 % white, counts as a container: the card traces as its lines and pictures, not as one block, and stays on screen under the skeleton while it loads, so only what's on it wipes in. Any other background would be traced as a solid shape, so mark it:
CardContent(item: item)
.padding()
.background {
RoundedRectangle(cornerRadius: 20)
.fill(.cardBackground)
.skeletonIgnored()
}
Side effects
To trace your view, Silhouette lays out a second copy of it. Work started in .task or .onAppear inside the skeleton would run for that copy too. Skip it there:
@Environment(\.isDrawingSkeleton) private var isDrawingSkeleton
var body: some View {
DetailView(item: item)
.task {
guard !isDrawingSkeleton else { return }
await model.loadComments()
}
}
Images are covered on their own: give each one a frame or an aspect ratio, since an image has no size until it loads.
Memory
Every Skeleton remembers what it showed, so its next skeleton is exact rather than drawn from the sample. By default the memory is keyed by where the Skeleton is in your code. Pass an id to share a shape between places, or to tell apart several instances of one line of code, such as a Skeleton inside a ForEach; otherwise they share one shape.
Skeleton(messages, sample: Message.samples, id: "inbox") { messages in
Inbox(messages: messages)
}
- Within a launch it keeps the real data last shown, in memory.
- Across launches, for
Codabledata, it keeps only the layout, inUserDefaults: a copy where every letter becomesnorN, every digit0, and every number a run of 8s with the same digit count. Spaces, punctuation and booleans stay, so the copy wraps like the original. A copy that no longer decodes is dropped.
Even a scrubbed shape gives away the outline of someone's data, and it is kept whether or not you pass an id. Clear every remembered shape on sign-out:
func signOut() async {
await session.end()
forgetSkeletonShapes()
}
Reveals
Reveal modes
A reveal is the moment content replaces its skeleton. Set one for every skeleton below a view:
ContentView()
.skeletonReveal(.smart)
| Reveal | What it does |
|---|---|
.smart | The default. Picks one of the others as each reveal lands; see below. |
.together | Crossfades the whole skeleton into the content in 0.2 s. |
.sequence | Row by row down its own region, each line wiping in where its bar was. |
.sweep | Uncovers the content behind one diagonal front, at the shimmer's slant and pace. Content taller than one and a half screens crossfades instead. |
.instant | Swaps at once. |
What smart decides
- A skeleton waits 150 ms before it shows. If the data beats that, there's never a skeleton, and the content simply appears.
- If someone scrolled in the last 400 ms, content appears at once rather than animating under their thumb.
- Otherwise content comes in row by row down the screen, 40 ms apart. On a long page the beat tightens so the last row starts within 0.45 s. An avatar beside a name and a handle is one row; each line of a paragraph is its own.
- Each line wipes in from its leading edge where its bar was, and the bar wipes out behind the same edge, so a line and its skeleton never show at once in one place. A waiting line hides only its letters, never the card behind them.
- Regions landing within 150 ms of each other wait for one another and rank every row together, so a page of cards reads as one motion. A region landing later waits for the lines above it, so the page always reads top to bottom. Rows off screen appear at once.
- The cascade keeps time by the frames it draws: if the app stalls, it waits rather than jumping ahead and showing every line at once.
- On reload, the content fades off its skeleton, which comes up underneath it as it goes.
- While loading, a region keeps its skeleton's height, so data arriving can't move the page; if the content is a different height, it eases there over 280 ms once the reveal starts.
Each line's wipe takes 0.3 s by default. A reveal never moves the page: the content was laid out in its skeleton's place all along. Under Reduce Motion, every reveal is instant.
Scrolling
For smart to know someone is scrolling, mark your scroll views. It needs iOS 18, macOS 15, tvOS 18, watchOS 11 or visionOS 2, and does nothing earlier.
ScrollView {
Feed(posts: posts)
}
.skeletonTracksScrolling()
Images
Images never hold a reveal back. Use SkeletonAsyncImage for remote images: the text around it reveals as soon as its data is there, and each image still downloading keeps shimmering in its own frame, then fades in.
SkeletonAsyncImage(url: photo.url) { image in
image.resizable().scaledToFill()
}
.frame(width: 120, height: 120)
.clipShape(.rect(cornerRadius: 12))
- Give it a size. An image has no size until it loads, so without a frame or an aspect ratio its skeleton has no room and the page moves when it arrives.
- The tracing copy draws it as one block and never downloads anything.
- A failed download leaves a quiet, still placeholder, since nothing more is coming.
- Images keep their own corner radius; the theme's radius is for lines of text and boxes.
Changing size
A skeleton drawn from a sample or from old data won't always match the new data's shape. When the real content is a different height, the region eases to it over 280 ms instead of snapping.
Easing is a fallback, not the goal. Each time it happens, a debug build logs how many points the skeleton was off, and the debug overlay labels the region in red with the distance. Fix it with a sample of typical length. The next skeleton is drawn from what was really shown, so it only happens once per place.
Your own reveal
Every built-in is a SkeletonReveal. Start from one and change what you need:
var blurIn = SkeletonReveal.sequence
blurIn.enter = .blur
ContentView()
.skeletonReveal(blurIn)
Unveil each piece from its top edge, or give a wipe an effect that paints the incoming content at each moment:
let unveil = SkeletonReveal(order: .byPosition, enter: .unveil)
let focus = SkeletonReveal(
wipe: .custom({ p in wipeDown(p) }, effect: { p in
.init(blur: 8 * (1 - p), scale: 0.98 + 0.02 * p)
}),
duration: 0.6
)
| Field | Meaning |
|---|---|
order | When each piece arrives: .together, .byPosition (sequence's), .byRow (smart's) or .custom with your own delay per piece. |
enter | Where content starts as it fades in: blur, offset, scale, rotation and clip, an edge to unveil from, like a CSS clip path. Presets .none, .blur, .rise, .zoom. |
wipe | A mask across the content for each moment of the reveal: .sweep or .custom. Replaces order; the outgoing skeleton gets its inverse. |
delay | Seconds before the reveal starts. |
duration | Seconds each piece's wipe takes, or the whole crossfade for a reveal that comes in together. 0.3 by default; 0 is instant. |
hold | Seconds a skeleton waits before it shows at all, so fast data never shows one. |
choose | Decides as content lands, from a RevealContext. Return a reveal to use, or nil to keep this one. |
A custom order
A .custom order gets each RevealPiece, one bar, image, control or shape, and returns its delay in seconds, or nil to show it at once. A piece knows its rect, the region's rect, its row on the page and how many rows there are, its row within its region, whether it's smaller text than the rest of its row, and the screen. Whatever delay you give it, the piece wipes in from its leading edge. The built-in orders are exported, so you can build on them:
// Bottom to top.
let rising = SkeletonReveal(order: .custom { piece in
let up = (piece.reveal.maxY - piece.rect.maxY) / max(piece.reveal.height, 1)
return min(max(up, 0), 1) * 0.6
})
// Smart's row-by-row cascade, at half the pace.
let unhurried = SkeletonReveal(order: .custom { piece in
RevealPiece.byRow(piece).map { $0 * 2 }
}, duration: 0.3)
A custom wipe
A wipe returns a gradient mask for each moment, from progress 0 to 1. Opaque stops show the content.
let wipeDown = SkeletonReveal(wipe: .custom { progress in
let at = progress * 1.2
return SkeletonReveal.WipeMask(stops: [
.init(color: .black, location: max(0, at - 0.2)),
.init(color: .clear, location: max(at, 0.001)),
])
}, duration: 0.4)
Deciding as it lands
let calm = SkeletonReveal(hold: 0.15, choose: { context in
if context.skeletonShownFor == nil { return .instant } // never showed
if context.isRefetch { return .together }
return context.size.height > 400 ? .sweep : nil // nil keeps this reveal
})
The reveal you return keeps the outer reveal's hold. Whatever you build, delays and durations stop at one second, the page never moves, and Reduce Motion makes it instant.
AsyncSkeleton
Give AsyncSkeleton the async work and the view. It runs the work when it appears, shows the skeleton while it waits, and reveals the content in place.
AsyncSkeleton(sample: Quote.sample, id: "quote", trigger: day) {
try await api.quote(for: day)
} content: { quote in
QuoteCard(quote: quote)
}
- Change
triggerto load again. While it reloads, the old content stays on screen. - It remembers its shape the same way
Skeletondoes, by its place in your code or byid, so after the first load it needs no sample. - A tracing copy inside another skeleton never starts the work.
- A thrown error shows its
localizedDescriptionin a quiet callout. For your own error view, hold the value yourself and useSkeletonwith.failure.
Styling
Theming
A SkeletonTheme sets how every skeleton below a view looks and moves. Set one near the root, and change single options for one part of the screen with the closure form.
ContentView()
.skeletonTheme(SkeletonTheme(
animation: .shimmer,
speed: .slow,
radius: .pill,
text: SkeletonTextMetrics(top: .capHeight, bottom: .descender)
))
Sidebar()
.skeletonTheme { $0.speed = .fast }
Try the options below on a card drawn the way Silhouette draws it, at the same pace and slant. The code underneath updates to match, listing only what differs from the defaults.
| Option | Values |
|---|---|
light, dark | A SkeletonColors(base:highlight:) for each colour scheme. Light is black at 7% with a white highlight at 60%; dark is white at 8% with white at 10%, which suits a true-black page. SkeletonColors.tinted(_:base:highlight:) builds both from one colour. |
colorScheme | Forces light or dark skeleton colours. nil, the default, follows the system. |
reducedMotion | What skeletons do under Reduce Motion: .holdStill (the default) shows the base colour with nothing moving; .pulse breathes quietly in place instead. |
animation | .shimmer (one band across the whole screen), .groupShimmer (a band across each region, edge to edge), .pulse or .none. |
speed | .slow (default), .normal, .fast or .seconds(_:). A shimmer loop takes 4, 3 or 2 seconds across a 1280-point screen and keeps that pace on any width; a pulse takes 2.4, 1.8 or 1.2 seconds. |
direction | .angle(.degrees(20)) by default, measured clockwise from left to right. Also .leadingToTrailing, .trailingToLeading, .topToBottom, .bottomToTop. Mirrored in right-to-left languages. |
bandWidth | The highlight's width in points. nil takes 40% of the screen's width, kept between 80 and 320 points. |
radius | How round lines of text and boxes are: .auto (in proportion to the height), .points(_:) or .pill. Images and chips keep their own shape. |
text | A SkeletonTextMetrics; see Text metrics. |
Text metrics
Each line of text becomes one bar, from its first glyph to its last. SkeletonTextMetrics sets how tall the bar is: from a top edge, the ascender, capHeight or xHeight, down to the descender or the baseline.
The default is cap height to descender, the shaded area above. SwiftUI sets lines with no extra leading, so bars from ascender to descender would touch the next line's and the lines would merge into one slab. For tight lists, try x-height to baseline.
CompactList()
.skeletonText(SkeletonTextMetrics(top: .xHeight, bottom: .baseline))
.skeletonText sets just the metrics for everything below a view, whatever the theme says. Bars are cut from the real glyph metrics on iOS 18, macOS 15, tvOS 18, watchOS 11 and visionOS 2 and later; earlier systems draw each line the way SwiftUI's own redaction does.
Shimmering text
For work that's under way rather than content that's missing, such as an AI tool call that's running, shimmer the line itself. The text rests at a quiet tone and a band of it at full strength passes over, on the same clock as every skeleton.
ShimmerText("Looking at your sleep")
ShimmerText(isActive: call.isRunning) {
Label(call.title, systemImage: "sparkle")
}
Text(call.title)
.shimmer(call.isRunning)
.shimmer(_:) works on any view, not only text. Under Reduce Motion it rests at its quiet tone and holds still, or breathes gently if the theme's reducedMotion is .pulse.
Reference
Accessibility
- While loading, a region is one VoiceOver element that reads its label, "Loading" by default, and never the sample. Pass
label:to say what's loading:label: Text("Loading profile"). - Skeletons are hidden from VoiceOver and from hit testing, and the hidden content can't be tapped.
- Once content has come in, Silhouette posts a layout-changed notification. Use
onRevealto move focus yourself, for example with@AccessibilityFocusState. - Under Reduce Motion skeletons hold still and every reveal is instant. Set the theme's
reducedMotionto.pulsefor a quiet pulse in place instead. - Skeletons follow Dynamic Type, because they are traced from your text as it's laid out at the current size.
SkeletonBoxheights in.emscale too. - Right-to-left layouts mirror, and so does the shimmer's direction.
@AccessibilityFocusState private var profileFocused: Bool
Skeleton(user, sample: .sample, label: Text("Loading profile"),
onReveal: { profileFocused = true }) { user in
ProfileCard(user: user)
.accessibilityFocused($profileFocused)
}
Debugging
A skeleton that doesn't match its content makes the page jump. The debug overlay finds those. Each loading region is outlined in blue, labelled with where its skeleton came from (sample, last shown, remembered, on screen, custom, content or fallback). When the content arrives the outline turns green if nothing moved, or red with how far it moved.
ContentView()
.skeletonDebug(.outlines) // or .all to add x-ray
setSkeletonDebug(.all) // the whole app, from code
Or add -SilhouetteDebug YES to the scheme's launch arguments, or -SilhouetteDebug xray for x-ray too. X-ray shows the hidden content faintly through its skeleton, so you can see what was traced.
Debug builds also log to the console, under the subsystem Silhouette: a sample to paste when a Skeleton has none, a warning when there was nothing to measure, how far a skeleton was off when the page moved, and when a skeleton has no size at all.
Data fetching
With Observation
Keep the value optional in your model and pass it straight through. The skeleton shows until the first value lands.
@Observable final class ProfileModel {
var user: User?
var isRefreshing = false
func load() async {
user = try? await api.user()
}
func refresh() async {
isRefreshing = true
defer { isRefreshing = false }
user = try? await api.user()
}
}
struct ProfileScreen: View {
@State private var model = ProfileModel()
var body: some View {
ScrollView {
Skeleton(model.user, sample: .sample, id: "profile",
isLoading: model.isRefreshing) { user in
ProfileCard(user: user)
}
}
.skeletonTracksScrolling()
.task { await model.load() }
.refreshable { await model.refresh() }
}
}
Refetching
Decide what a refetch should look like. Leave isLoading out and the old content stays on screen until the new data replaces it. Pass isLoading: and the content goes straight back to its skeleton, drawn from what's on screen, then .smart brings the new data in with a quick crossfade.
Where to start work
Start loading from a .task outside the skeleton, as above. If the work has to live inside the content, guard it with \.isDrawingSkeleton, or the traced copy starts it too.
Lists
Put skeletons on rows, not around a List. A list lays its rows out lazily, so there's no whole list to trace. Show sample rows while loading, each with its own region:
List(model.messages ?? Message.samples) { message in
MessageRow(message: message)
.skeleton(isLoading: model.messages == nil)
}
Give the samples distinct ids. Smart reveals still read as one cascade down the screen, because rows that land together share one order.
Testing
UI tests
Skeletons are hidden from accessibility, and while a region loads its content is hidden too, behind one element labelled "Loading" (or your label). So queries by label or identifier never find the sample. Wait for the real content instead:
let name = app.staticTexts["Ada Lovelace"]
XCTAssertTrue(name.waitForExistence(timeout: 5))
Launch with -SilhouetteInstant YES and every reveal is instant and every skeleton holds still, so UI tests and screenshots never wait on motion:
app.launchArguments += ["-SilhouetteInstant", "YES"]
To skip reveal animations, set the instant reveal when the app runs under UI tests:
ContentView()
.skeletonReveal(ProcessInfo.processInfo.arguments.contains("-UITests") ? .instant : .smart)
Snapshot tests
The shimmer is timed by the wall clock, so a snapshot of a loading state changes from run to run. Hold it still for snapshots with .skeletonTheme { $0.animation = .none }.
Custom orders
RevealPiece and RevealContext have public initialisers, so you can unit-test your own order or choose without any views: build a piece, call your closure, check the delay.
Troubleshooting
The page jumps when content arrives
Turn on debugging to see where the skeleton came from and how far the content moved. Most often the sample is shorter or longer than real data: give it typical lengths. The next skeleton is drawn from what was really shown, so it will be exact.
A whole card is one solid block
Its background isn't the page's colour, so it was traced as a shape. Add .skeletonIgnored() to the background view, inside .background { }, not to the card.
Three grey lines and a warning in the console
There was nothing to measure: no sample, no remembered shape, no data on screen. This happens on the very first load of a Skeleton without a sample; after that its shape is remembered. Pass a sample: so the first load looks right too. For a single placeholder, use SkeletonBox.
An image has no skeleton, or moves when it loads
It had no size until it loaded. Give it a .frame or an .aspectRatio. Debug builds log when a skeleton has no size.
Network requests run twice
The traced copy of your view ran a .task or .onAppear. Start work outside the skeleton, or guard it with \.isDrawingSkeleton.
A chart, map or icon row shimmers as noise
Mark it with .skeletonBlock(cornerRadius:), or draw its outline with .skeletonShape { }. Maps, web views and video players are drawn by the system, not SwiftUI, and need a block.
Lines of text merge into one slab
The bars are too tall for the line spacing. Keep the default cap height to descender, or try .skeletonText(SkeletonTextMetrics(top: .xHeight, bottom: .baseline)).
Text bars look like plain redaction
Bars are cut from the font's metrics on iOS 18, macOS 15, tvOS 18, watchOS 11 and visionOS 2 and later. On earlier systems they follow SwiftUI's own redaction.
Content animates in while I'm scrolling
Add .skeletonTracksScrolling() to the scroll view so .smart can see the scroll and reveal at once. It needs iOS 18 or the matching releases.
Skeletons hold still, and reveals don't animate
Reduce Motion is on. That's deliberate: skeletons hold still and reveals are instant. For a quiet pulse instead, set reducedMotion: .pulse on the theme.
API
Skeleton
| Parameter | Type | Meaning |
|---|---|---|
_ data | Value? | The data to show. The skeleton shows while it's nil. |
sample | Value? | Stands in for the data to draw the first skeleton. |
id | String? | The key the shape is remembered under; across launches for Codable data. Defaults to this Skeleton's place in your code. |
isLoading | Bool | Shows the skeleton even over data. false by default. |
label | Text? | Read by VoiceOver while loading. "Loading" by default. |
onReveal | (() -> Void)? | Called once the content has come in over a skeleton. |
content | (Value) -> Content | Your view, built from the data. |
| Option | Meaning |
|---|---|
.placeholder { } | Draws this instead of the traced skeleton. |
.empty(_:message:) | Shows the message in place of the content when the data has arrived and the flag is true. |
.failure(_:content:) | Shows your view for a non-nil error in place of everything else. |
.skeleton(isLoading:label:onReveal:)
| Parameter | Type | Meaning |
|---|---|---|
isLoading | Bool | Whether to show the skeleton of this view. |
label | Text? | Read by VoiceOver while loading. |
onReveal | (() -> Void)? | Called once the content has come in. |
AsyncSkeleton
| Parameter | Type | Meaning |
|---|---|---|
sample | Value? | Draws the skeleton while the work runs. |
id | String? | The key the shape is remembered under. Defaults to its place in your code. |
trigger | AnyHashable? | Change it to run the work again. |
label | Text? | Read by VoiceOver while loading. |
onReveal | (() -> Void)? | Called once the content has come in. |
load | @Sendable () async throws -> Value | The work. Value must be Sendable. |
content | (Value) -> Content | Your view, built from the result. |
SkeletonBox
| Parameter | Type | Default |
|---|---|---|
width | SkeletonLength | .fraction(0.6) |
height | SkeletonLength | .em(1), one line of body text |
radius | SkeletonRadius? | nil, the theme's radius |
SkeletonAsyncImage
| Parameter | Type | Meaning |
|---|---|---|
url | URL? | The image to load. |
scale | CGFloat | The image's scale. 1 by default. |
content | (Image) -> Content | Your view of the loaded image. Leave it out to show the image as it is. |
ShimmerText and .shimmer(_:)
| Form | Meaning |
|---|---|
ShimmerText(_:isActive:) | A line of text from a string or localized key. |
ShimmerText(isActive:label:) | Any view. |
.shimmer(_ isActive: Bool = true) | Passes the shimmer over a view's own pixels. |
Modifiers
| Modifier | Meaning |
|---|---|
.skeletonBlock(cornerRadius:) | One block for this view instead of tracing it. |
.skeletonIgnored() | Leaves this view out of the skeleton; it keeps its space. |
.skeletonShape { } | Your own skeleton for this view, in its frame. |
.skeletonTheme(_:) | Sets the theme below this view. |
.skeletonTheme { $0.x = … } | Changes part of the theme below this view. |
.skeletonText(_:) | Sets the text metrics below this view, whatever the theme says. |
.skeletonReveal(_:) | Sets how content replaces its skeleton below this view. |
.skeletonTracksScrolling() | Lets .smart see scrolling in this scroll view. iOS 18 and matching releases. |
.skeletonDebug(_:) | The debug overlay below this view: .outlines (default), .xray or .all. |
Functions and environment
| Name | Meaning |
|---|---|
forgetSkeletonShapes() | Clears every remembered shape, in memory and on disk. Main actor. |
setSkeletonDebug(_:) | Turns the debug overlay on for the whole app. Main actor. |
\.isDrawingSkeleton | true in the copy of your view being traced. |
\.skeletonTheme | The current SkeletonTheme. |
\.skeletonReveal | The current SkeletonReveal. |
\.skeletonDebug | The current SkeletonDebugOptions. |
SkeletonTheme
| Property | Type | Default |
|---|---|---|
light | SkeletonColors | .defaultLight: black 7%, white 60% |
dark | SkeletonColors | .defaultDark: white 8%, white 10% |
animation | SkeletonAnimation | .shimmer |
speed | SkeletonSpeed | .slow |
direction | ShimmerDirection | .angle(.degrees(20)) |
bandWidth | CGFloat? | nil: 40% of the screen, 80 to 320 pt |
radius | SkeletonRadius | .auto |
text | SkeletonTextMetrics | cap height to descender |
colorScheme | ColorScheme? | nil: follows the system |
reducedMotion | SkeletonReducedMotion | .holdStill; or .pulse |
| Type | Cases and members |
|---|---|
SkeletonColors | base, highlight, .defaultLight, .defaultDark, .tinted(_:base:highlight:) (0.08 and 0.10 by default) |
SkeletonAnimation | .shimmer, .groupShimmer, .pulse, .none |
SkeletonSpeed | .slow, .normal, .fast, .seconds(_:); shimmerLoop, pulseLoop |
ShimmerDirection | .leadingToTrailing, .trailingToLeading, .topToBottom, .bottomToTop, .angle(_:) |
SkeletonRadius | .auto, .points(_:), .pill |
SkeletonTextMetrics | top: .ascender, .capHeight, .xHeight; bottom: .descender, .baseline |
SkeletonLength | .points(_:), .fraction(_:), .em(_:); number literals are points |
SkeletonDebugOptions | .outlines, .xray, .all |
SkeletonSource | .onScreen, .lastShown, .remembered, .sample, .custom, .content, .fallback |
SkeletonReveal
| Property | Type | Default |
|---|---|---|
order | Order | .together |
enter | Enter | .none |
wipe | Wipe? | nil |
delay | Double | 0, capped at 1 s |
duration | Double | 0.2 per piece, capped at 1 s |
hold | Double | 0 (.smart holds 0.15) |
choose | (@Sendable (RevealContext) -> SkeletonReveal?)? | nil |
| Type | Cases and members |
|---|---|
| Built-ins | .smart, .together, .sequence, .sweep (0.6 s), .instant |
Order | .together, .custom((RevealPiece) -> Double?), .byPosition, .byRow |
Enter | blur, offset, scale, rotation; .none, .blur (6), .rise (6 pt), .zoom (0.97) |
Wipe | .sweep, .custom((Double) -> WipeMask) |
WipeMask | stops, startPoint (.top), endPoint (.bottom) |
RevealPiece
| Member | Meaning |
|---|---|
rect | The piece, in screen coordinates. |
reveal | The whole region being revealed. |
unit | The piece's row: the pieces that sit together with it. nil if alone. |
isSecondary | Smaller text than the largest in its row. |
row, rows | Its row on screen, counting from the top, among every reveal landing with it, and how many rows there are. |
regionRow, regionRows | Its row within its own region, and how many that region has. |
screen | The screen the reveal is on. |
byPosition(_:), byRow(_:) | The built-in orders, to build on. |
rowStagger, longestCascade, stagger(rows:) | 0.04 s between rows; the last row starts within 0.45 s; the beat for a given number of rows. |
RevealContext
| Member | Meaning |
|---|---|
skeletonShownFor | Seconds the skeleton was up, or nil if the data beat the hold. |
size | The size of the content arriving. |
pieces | How many pieces the skeleton had. |
isRefetch | The content had loaded before. |
isInteracting | Someone scrolled in the last 400 ms. |
reduceMotion | Reduce Motion is on. |
Platform support
| Platform | Minimum | Glyph-exact text and scroll tracking |
|---|---|---|
| iOS and iPadOS | 17 | 18 |
| macOS | 14 | 15 |
| tvOS | 17 | 18 |
| watchOS | 10 | 11 |
| visionOS | 1 | 2 |
Below the second column, each line of text is drawn the way SwiftUI redacts it rather than cut from the font's metrics, and .skeletonTracksScrolling() does nothing. Everything else works the same. The package uses Swift 6 tools and language mode, so you need Xcode 16 or later.
How it works
Silhouette doesn't guess at sizes. It lets SwiftUI lay out the real view, then reads the result.
- Laid out by SwiftUI. Your content renders in place from the closest data there is, at zero opacity, so every size and line break is SwiftUI's own.
- A traced copy. A second copy, with
\.isDrawingSkeletonset, is laid out in the same space and drawn into a canvas. A text renderer turns each line into one bar trimmed to the font's metrics; images, controls and painted shapes draw as they are. - Coverage. Each pixel is measured by how far it is from the page's colour, so anything painted becomes solid and surfaces near the page's colour drop out. That shape masks the skeleton fill.
- One clock. The highlight's position comes from the wall clock and the skeleton's place on screen, so every skeleton shimmers as one, however late it appeared.
- Pieces. For an ordered reveal, the traced shape is drawn again offscreen and split into connected areas: each bar, image, control and shape is one piece, grouped into rows.
- The reveal. The content fades, wipes or rises in over its skeleton, piece by piece, in the space it already held.
Changelog
Unreleased
- Reveals wipe each line in where its bar was, row by row down the page, a beat apart. Regions landing together wait for one another and share one cascade, a waiting line hides only its letters, content fades off its skeleton on reload, and a region keeps its height while loading. New orders
.byPosition,.byRowand.custom. - The shimmer keeps one pace on any screen width, slanted at 20 degrees by default.
- Under Reduce Motion skeletons hold still, as Skullet's do. A quiet pulse is an opt-in:
reducedMotion: .pulse. .skeletonTracksScrolling(), so content landing mid-scroll appears at once.- Reloading content goes straight to its skeleton, with no blank beat.
- Under Reduce Motion every reveal is instant.
- A
SkeletonorAsyncSkeletonwithout anidremembers its shape by where it is in your code.
First version
- Skeletons traced from your real layout:
Skeleton,.skeleton(isLoading:),AsyncSkeleton,SkeletonBox,SkeletonAsyncImage,ShimmerText. - Hints, memory by id, themes, reveals and the debug overlay.
Every demo on this page is a screen styled after Halo, Terramind's health app, recorded from Silhouette's demo app with Halo's photographs.