This article accompanies the public reference app DesignSystem GitHub repository. The goal is not to show a large catalog of UI pieces. The goal is to show how design-system decisions were made, which alternatives were rejected, and why the resulting architecture is intentionally small.
UI maturity is not measured by token count or component count. It is measured by whether the system improves delivery under real constraints: accessibility, adaptation, consistency, and maintainability.
Why this design-system companion app exists
Most “design system in SwiftUI” examples optimize for visual output. Real product work needs a different question:
This companion app was built to make decision boundaries explicit:
- what remains platform-owned
- what becomes product-owned
- what is still intentionally unresolved
The objective is evidence, not novelty.
Investigation model used for every decision
The implementation follows one repeatable flow:
Problem -> Investigation -> Implementation -> Stress test -> Evidence -> Production implicationsThis keeps the app from becoming a gallery of polished components detached from real constraints.
Scope on purpose: a narrow but representative system
Instead of adding dozens of components, the app implements a small set that creates useful architectural pressure:
DSTokenBundleand theme propagation viaEnvironmentValuesDSButtonwith typed role/size/state APIDSFieldwith explicit field states and native input behavior- composed patterns (
DSCard,DSListRow,DSFeedbackBanner,DSStatusBadge)
This is enough to validate ownership boundaries without premature framework growth.
Decision 1: Token layering over one giant theme object
Problem
Hard-coded values scattered across components make change expensive and inconsistent.
Decision
Use token layers with explicit ownership in DesignSystem/DesignSystem/DSTokens.swift:
- primitive tokens (raw values)
- semantic tokens (intent)
- component tokens (local contract decisions)
Practical token shape
The key is not “more tokens.” The key is stable ownership per layer.
| Layer | Example in project | Ownership question |
|---|---|---|
| Primitive | DSPrimitiveSpacing.md = 12 | What is the raw measurement/value? |
| Semantic | DSSemanticActions.primary | What does this mean in UI intent? |
| Component | DSButtonComponentTokens.verticalPadding | How should this specific reusable API express that intent? |
In practice, this prevents common drift patterns like “button padding copied into five screens” or “one-off color constants added during hotfixes.”
Primitive layer example
Primitive values keep brand and geometry decisions centralized:
return Self(
spacing: .init(xs: 4, sm: 8, md: 12, lg: 16),
radius: .init(card: 14, control: 12, badge: 999),
border: .init(subtle: 1),
brand: brand
)Semantic layer example
Semantic tokens mix system-owned meaning with product-owned accent decisions:
static func make(from primitives: DSPrimitiveTokens) -> Self {
Self(
text: .init(primary: .primary, muted: .secondary, onAccent: .white),
surfaces: .init(
primary: Color(uiColor: .secondarySystemBackground),
accent: primitives.brand.accentSoft
),
actions: .init(
primary: primitives.brand.accent,
pressed: primitives.brand.accentPressed
)
)
}Component layer example
Component tokens turn shared semantics into concrete reusable contracts:
button: .init(
background: semantics.actions.primary,
foreground: semantics.text.onAccent,
cornerRadius: 12,
horizontalPadding: 14,
verticalPadding: 10
)Why this matters
A brand decision changes one source and propagates through component contracts instead of triggering piecemeal styling edits.
Trade-off
More indirection up front. Accepted because it reduces long-term drift.
Decision 2: Theme resolution at boundary, not prop drilling
Problem
Passing token bundles through every view layer creates API noise and coupling.
Decision
Resolve tokens once from environment (colorScheme, contrast, Dynamic Type) and inject via .dsTheme(...).
content
.environment(\.dsTokenBundle, tokenBundle)Practical resolution logic
DSTokenBundle.make(for input:) resolves adaptation once and keeps leaf components simple:
let isAccessibilitySize = input.dynamicTypeSize.isAccessibilitySize
let isHighContrast = input.colorSchemeContrast == .increased
let semanticSpacing = DSSemanticSpacing(
stack: isAccessibilitySize ? base.semantics.spacing.stack + 2 : base.semantics.spacing.stack,
inline: base.semantics.spacing.inline,
cardPadding: isAccessibilitySize ? base.semantics.spacing.cardPadding + 2 : base.semantics.spacing.cardPadding
)
let semanticBorders = DSSemanticBorders(
subtle: base.semantics.borders.subtle,
width: isHighContrast ? max(2, base.semantics.borders.width) : base.semantics.borders.width
)Instead of teaching every component how to react to contrast and Dynamic Type, the system resolves one coherent token bundle at the themed subtree boundary.
Production implication
Components consume semantic context directly. Feature-level APIs stay focused on behavior, not style transport.
What this avoids
Parent(tokenBundle)
-> Section(tokenBundle)
-> Row(tokenBundle)
-> Leaf(tokenBundle)That threading pattern scales coupling faster than it scales reuse.
Decision 3: Semantic component APIs over boolean explosion
Problem
Boolean-heavy APIs (isPrimary, isSecondary, isLarge, isLoading) allow invalid combinations and unclear precedence.
Decision
Model shared controls with explicit enums:
DSButtonRoleDSButtonSizeDSButtonState
Usage in the companion app
DSButton(
"Save",
role: .primary,
size: .regular,
state: canSave ? .enabled : .disabled,
action: save
)This API prevents contradictory combinations that boolean sets allow (for example, isPrimary && isSecondary).
State resolution in one place
if state == .disabled {
bg = tokenBundle.semantics.actions.primary.opacity(0.55)
} else if isPressed {
bg = tokenBundle.semantics.actions.pressed
} else {
bg = tokenBundle.semantics.actions.primary
}The value is not cosmetic. It gives one maintainable source for pressed/disabled/loading behavior across call sites.
Production implication
You get constrained, understandable usage and centralized visual/state resolution.
Trade-off
Slightly more type modeling. Accepted because correctness and API clarity improve.
Decision 4: Preserve native behavior contracts by default
Problem
Custom controls often replace platform semantics accidentally.
Decision
Use native Button, TextField, and SecureField behavior as baseline, then layer design-system styling and state contracts on top.
Production implication
Accessibility, focus, keyboard behavior, and system evolution remain aligned by default.
Rule
Customize expression first. Customize behavior only when requirements justify re-ownership.
What this implementation does not claim
This app is intentionally not:
- a complete enterprise design-system package
- an exhaustive component library
- final visual language for all product contexts
- proof that more modules or more components means higher maturity
It is a production-minded decision artifact.
Evidence currently demonstrated in the companion app
- live theme switch (Ocean, Plum) from one token source
- consistent state-driven behavior across button/field/banner patterns
- environment-aware token resolution (contrast, Dynamic Type, scheme)
- composed components built from shared semantic primitives
- clear anti-drift architecture: token ownership separated by layer
- a practical “edit one token, observe multiple surfaces update” workflow in
ContentView
If you run the app and switch theme while toggling states, you can inspect the exact boundary where primitive values stop and semantic/component contracts take over.
Progression that shaped the system
The most relevant outcome from the journal is not a list of milestones. It is the progression of constraints that forced better decisions over time:
- start with a native baseline so behavior and accessibility contracts are visible,
- introduce custom expression in narrow slices,
- compare tokenized implementation against a deliberately flawed alternative,
- stress the result under adaptation pressure,
- and only then promote patterns as reusable contracts.
That progression changed implementation choices in practical ways:
- From visual imitation to semantic ownership: values moved from local constants into primitive/semantic/component token layers.
- From one-state demos to contract-driven APIs: components modeled explicit roles and states (
role,size,state) instead of ad-hoc flags. - From “looks right” to evidence-backed confidence: adaptation checks (contrast, Dynamic Type, directionality, feedback states) became part of decision quality.
Baseline and anti-pattern pairing
A recurring pattern in the journal is pairing each accepted approach with a nearby anti-pattern. That made trade-offs explicit and easier to validate.
Accepted: semantic token + native behavior + typed state API
Rejected: copied raw values + behavior look-alikes + boolean sprawlFidelity and promotion discipline
Another progression outcome is the separation between “implemented” and “promoted.” A reusable decision is promoted only when ownership and evidence are clear.
Promotable when:
- semantic ownership is clear,
- mapping/token usage is traceable,
- adaptation checks pass,
- and residual deltas are classified (bug, adaptation, customization, unresolved).This is what keeps the system from becoming a set of visually consistent but operationally fragile components.
Known limits (explicit, not hidden)
- token taxonomy is still compact (no full typography/elevation/motion suite yet)
- no full snapshot test matrix committed yet
- no CI gate enforcing component promotion criteria yet
- still one app target (module extraction intentionally deferred)
These are not oversights. They are staged decisions to avoid premature abstraction.
Practical production path from here
Next steps are quality-oriented, not volume-oriented:
- Expand semantic tokens where repeated pressure exists (typography, status, motion).
- Add component preview matrices for stress scenarios (Dynamic Type, RTL, contrast, dark mode).
- Add behavior + snapshot tests for shared families.
- Introduce promotion gates: accessibility pass, state-contract pass, and documented rationale.
Suggested next token additions (pressure-driven)
DSSemanticStatus(success, warning, critical, info) to unify banners, badges, and inline validation.- Typography tokens for reusable role-based text (title, body, meta) where repetition starts creating drift.
- Motion tokens only after repeated transition timing pressure appears.
- Elevation tokens only when layered surfaces need deterministic hierarchy beyond system material defaults.
Closing principle
A design system is not “done” when it has many components. It starts to become production-ready when each decision is traceable:
- ownership is clear
- behavior is intentional
- adaptation is verified
- trade-offs are explicit
That is the real purpose of this companion app: to show not only what was built, but why this level of system ownership is worth building.