Skip to content

Loading ​

A loading indicator. On the SwiftUI end it is a self-drawn ring (Circle().trim + a rotation animation); the duration comes from motion.duration.base (seconds).

Spec source: lh-ui-core/specs/loading.json · Golden cases: lh-ui-core/cases/loading.json (5 entries, translated into XCTest, runnable on the macOS host)

Tone ​

Five tones take the semantic color tokens; the default is .primary.

9:41Loading tones

HTML mock preview (iOS / SwiftUI appearance), not an on-device render

swift
LhLoading(tone: .success)

Sizes ​

Three sizes map to the loading.size tokens; the stroke width comes from loading.strokeWidth.

9:41Loading sizes

HTML mock preview (iOS / SwiftUI appearance), not an on-device render

Static frame ​

animating: false freezes the rotation (the golden case render-emits-ring-command asserts the draw parameters of the static ring), which is useful for screenshot tests and static documentation frames.

swift
LhLoading(lhSize: .large, animating: false)

API ​

Props ​

PropDescriptionTypeDefault
lhSizeRing size, mapped to the size tokensLhLoadingSize.medium
toneRing tone, mapped to the semantic color tokensLhLoadingTone.primary
animatingWhether to rotate (false freezes it into a static frame)Booltrue

LhLoadingSize ​

ValueSize
.smallloading.size.small (16pt)
.mediumloading.size.medium (20pt)
.largeloading.size.large (24pt)

LhLoadingTone ​

ValueColor
.primarycolor.primary.default
.successcolor.success.default
.warningcolor.warning.default
.dangercolor.danger.default
.infocolor.info.default

Token Reference ​

TokenPurpose
loading.size.{small,medium,large}Three sizes
loading.strokeWidthRing stroke width
color.{primary,success,warning,danger,info}.defaultFive tones
motion.duration.baseDuration of one rotation (seconds on the iOS end)

Golden Case Mapping ​

case idAssertionLocal test
medium-size-uses-medium-tokenThe medium size takes the medium size tokentestMediumSizeUsesMediumToken
large-size-uses-large-tokenThe large size takes the large size tokentestLargeSizeUsesLargeToken
primary-tone-uses-primary-tokenThe primary tone takes the primary tokentestPrimaryToneUsesPrimaryToken
success-tone-uses-success-tokenThe success tone takes the success tokentestSuccessToneUsesSuccessToken
render-emits-ring-commandThe ring stroke consumes the strokeWidth tokentestRingUsesStrokeWidthToken

Plus dedicated dark-mode tests: testDarkColorsComeFromDarkTokens / testDimensionsAreIdenticalInDarkMode / testLoadingViewInitAndRender.

bash
swift test --filter LhLoadingTests    # Runs on the macOS host, no simulator required

lh-ui native bloodline · iOS (Swift + SwiftUI)