From a design system to SwiftUI
The example throughout is Oat Margin (open the style). Its DESIGN.md defines color roles for light and dark, a type scale, radii and spacing. The goal is one file, Theme.swift, that every view imports, so that no view contains a literal color or font size.
1. Colors: one token, two appearances
Define each color once with its light and dark value, named by role. The initializer below wraps a dynamic UIColor, so the color follows the system appearance without an asset catalog. These values are the style's real tokens:
import SwiftUI
// Tokens from the "Oat Margin" DESIGN.md (stringers.io/en/styles/?s=oat-margin)
extension UIColor {
convenience init(hex: UInt32) {
self.init(red: CGFloat((hex >> 16) & 0xFF) / 255, green: CGFloat((hex >> 8) & 0xFF) / 255,
blue: CGFloat(hex & 0xFF) / 255, alpha: 1)
}
}
extension Color {
init(hex: UInt32) { self.init(uiColor: UIColor(hex: hex)) }
/// One token, two appearances: resolves with the system light / dark setting.
init(light: UInt32, dark: UInt32) {
self.init(uiColor: UIColor { $0.userInterfaceStyle == .dark ? UIColor(hex: dark) : UIColor(hex: light) })
}
}
enum Theme {
static let primary = Color(hex: 0xD8523F)
static let barRest = Color(hex: 0xCDC8BF)
static let paper = Color(light: 0xF4F1EB, dark: 0x1C1A17)
static let well = Color(light: 0xE5E1DC, dark: 0x2A2723)
static let hairline = Color(light: 0xDEDAD2, dark: 0x34302B)
static let ink = Color(light: 0x2E2B27, dark: 0xEDE8DF)
static let text = Color(light: 0x3F3B35, dark: 0xD6D0C6)
static let secondary = Color(light: 0x7A7671, dark: 0x9C968D)
static let tertiary = Color(light: 0xA39F99, dark: 0x6F6A63)
}
extension Font {
static let heroFigure = Font.system(size: 84, weight: .bold)
static let readingTitle = Font.system(size: 34, weight: .bold)
static let pageTitle = Font.system(size: 33, weight: .bold)
static let sectionHead = Font.system(size: 20, weight: .bold)
static let body = Font.system(size: 18.5, weight: .regular)
static let rowLabel = Font.system(size: 18, weight: .regular)
}Use them by role: Theme.paper behind everything, Theme.ink for primary text, Theme.secondary for supporting text, Theme.hairline for separators, Theme.primary for the one accent. If you prefer asset catalogs, create a Color Set per role with Any and Dark appearances and expose it as Color("paper"); the rule is the same, roles and not hues.
Two rules keep a palette intact as the app grows:
- No literals in views.
Color(hex:)appears only inTheme.swift. - No opacity tricks for text.
.opacity(0.6)on a label produces a color the system never defined and that fails contrast on some backgrounds. Use thesecondaryandtertiarytokens.
2. Typography: roles, not sizes
The Font extension above gives each role a name. Three details matter in practice:
- Design variants are free.
Font.system(size:weight:design:)with.serifgives New York,.roundedgives SF Rounded and.monospacedgives SF Mono, with no font files to bundle. Most styles in the library build their identity from these. - Fixed sizes do not scale with Dynamic Type. Wrap the size in
@ScaledMetricwhere the text should grow with the user's setting:
struct BodyText: View {
@ScaledMetric(relativeTo: .body) private var size: CGFloat = 18.5
let text: String
var body: some View {
Text(text)
.font(.system(size: size, weight: .regular))
.lineSpacing(size * 0.5) // DESIGN.md lineHeight 1.5 means roughly 0.5 × size of extra leading
.foregroundStyle(Theme.text)
}
}- Tracking comes from the spec. Large titles in most systems are set tight. Apply
.tracking(-0.7)where the token says so; it is a large part of why a reference screen looks designed and a defaultTextdoes not.
3. Surfaces: paper, hairlines and materials
How a style separates layers is its most recognizable trait, and the place where a default SwiftUI app drifts into generic cards. Three common families:
// Paper: flat color, separation by a hairline. No shadow.
struct PaperRow: ViewModifier {
@Environment(\.displayScale) private var scale
func body(content: Content) -> some View {
content
.padding(.vertical, 14)
.frame(maxWidth: .infinity, alignment: .leading)
.overlay(alignment: .bottom) {
Rectangle().fill(Theme.hairline).frame(height: 1 / scale)
}
}
}
// Tonal well: a slightly darker inset on the same paper.
struct Well: ViewModifier {
func body(content: Content) -> some View {
content
.padding(16)
.background(Theme.well, in: RoundedRectangle(cornerRadius: 14, style: .continuous))
}
}
// Glass: a system material over content, with a lit rim.
struct GlassPanel: ViewModifier {
func body(content: Content) -> some View {
content
.padding(18)
.background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 26, style: .continuous))
.overlay {
RoundedRectangle(cornerRadius: 26, style: .continuous)
.strokeBorder(.white.opacity(0.5), lineWidth: 0.5)
}
}
}
extension View {
func paperRow() -> some View { modifier(PaperRow()) }
func well() -> some View { modifier(Well()) }
func glassPanel() -> some View { modifier(GlassPanel()) }
}Pick the family the style specifies and use only that one. A hairline is one device pixel (1 / displayScale), not one point. Corners use style: .continuous; the circular default is visibly different at large radii.
4. Spacing and radius as constants
enum Space { static let xs: CGFloat = 4, s: CGFloat = 8, m: CGFloat = 16, l: CGFloat = 24, xl: CGFloat = 40 }
enum Radius { static let chip: CGFloat = 8, card: CGFloat = 14, panel: CGFloat = 26 }Replace the values with the scales from your style's DESIGN.md. When a view needs a value that is not on the scale, that is a design question, not a reason to type a new number.
5. Let an agent do the translation
With the skill installed, the whole of this section is one request. The agent downloads the style's DESIGN.md, writes Theme.swift from it, and builds screens that reference only tokens:
npx skills add komako-workshop/stringersUse Stringers to build this app's UI in the Oat Margin style. Create Theme.swift first.How the file works and how to keep an agent on it is covered in DESIGN.md for Claude Code and Cursor.
12 styles across six app types
The library sorts its 301 styles into six app types (a style can belong to two):
| App type | Styles |
|---|---|
| Minimal & Modern | 140 |
| Dark & Instrument | 116 |
| Playful & Illustrated | 97 |
| Bold & Graphic | 88 |
| Editorial & Print | 86 |
| Retro & Tactile | 31 |
Below are two from each, a light and a dark where the type has both. These are curated design systems with demo reference screens; open one to see all four screens and the full DESIGN.md.
Minimal & Modern
NativeClear glass over a quiet canvas
Fathom VeilWhite type afloat on dusk-blue water, behind panes of sea glass
Editorial & Print
Butter HatchPen-hatched doodles on butter paper, tilted stickers and a fat friendly serif
Canted CarouselLay photos across seams into one long frame
Dark & Instrument
Onyx ChaptersA black deck where a notched white line counts the chapters
Ember RibbonMolten sound ribbons gliding across a warm-black stage
Playful & Illustrated
Moss ChorusHear a bird once, know its name
Pasture GlassA fluffy owlet keeps your daily reading place
Retro & Tactile
Brushed ReelBrushed aluminium faceplate, black readout strip, one red dot
Brass FretlightLamplit guitar lessons that fit your evening
Bold & Graphic
Stompbox GigEvery practice session is tonight's headline show
Midnight FlyerLoud flyers on a black wall, each one lighting its own page
How to choose a style for a SwiftUI app
- Match the content shape, not the category. A style built around large figures suits trackers and dashboards; one built around text rows suits readers and notes; one built around cover grids suits media and collections.
- Decide the surface model first: paper and hairlines, tonal wells, or glass. Everything else follows from it.
- Look at both appearances. If the style defines light and dark tokens, ship both; if it defines one, lock the app to it with
.preferredColorSchemeand do not improvise the other. - Count the accents. The strongest styles use one, in one place per screen.
- Check the densest screen, not the hero. A style that looks good on an empty state and falls apart in a 40-row list is the wrong style.
SwiftUI checklist before you ship a styled app
- All colors and fonts come from
Theme.swift. - Text scales with Dynamic Type, or the app has a reason it does not.
- Body text contrast is at least 4.5:1 in both appearances.
- Hairlines are
1 / displayScale; corners are.continuous. - Tap targets are at least 44 by 44 points.
- Safe areas are respected; nothing sits under the home indicator.
- The app passes the App Store review checklist for SwiftUI.