Integration
iOS & SwiftUI
Konstrukt ships a generated Swift package so native apps use the exact same token values as the web. Colors, spacing, radius, and font names are all typed.
1 · Add the package
The package is generated at apps/konstrukt/dist/swift/Konstrukt. Reference it by local path from a sibling app, or pin a tagged release once published.
// Package.swift
dependencies: [
.package(path: "../hooman-loop/apps/konstrukt/dist/swift/Konstrukt"),
],
targets: [
.target(name: "App", dependencies: ["Konstrukt"]),
]
2 · Resolve a theme
A KonstruktTheme is the intersection of a palette and a mode — the same two axes as the web.
import Konstrukt let theme = KonstruktTheme.theme(palette: .hl, mode: .dark) // theme.accent, theme.bg, theme.surface, theme.text, ...
| Type | Cases |
|---|---|
KonstruktPalette | .atelier · .courage · .minimal · .hl · .blueprint |
KonstruktMode | .light · .dark |
3 · Use the environment
Inject a theme once near the root, then read it anywhere with @Environment.
import SwiftUI
import Konstrukt
struct RootView: View {
@Environment(\.colorScheme) private var scheme
var body: some View {
ContentView()
.konstruktTheme(palette: .hl, mode: scheme == .dark ? .dark : .light)
}
}
struct ContentView: View {
@Environment(\.konstruktTheme) private var theme
var body: some View {
VStack(spacing: KonstruktSpacing.sp4) {
Text("The Hooman Loop")
.font(.custom(KonstruktFont.display, size: 28))
.foregroundStyle(theme.text)
Text("Build once. Theme everywhere.")
.foregroundStyle(theme.textMuted)
}
.padding(KonstruktSpacing.sp6)
.background(theme.surface)
}
}
4 · Spacing, radius, fonts
KonstruktSpacing.sp1 // 4 KonstruktSpacing.sp4 // 16 KonstruktSpacing.sp16 // 64 KonstruktRadius.base // 0 (square corners) KonstruktFont.display // "Space Grotesk" KonstruktFont.sans // "Inter" KonstruktFont.mono // "SF Mono"
Register Space Grotesk and Inter in your app bundle (Info.plist UIAppFonts) to render the display and body families; SF Mono ships with the system.
Regenerating
The Swift sources are generated — never hand-edit them. Change a value in apps/konstrukt/tokens/ and rebuild; the CSS, Swift, and JSON outputs update together.
cd apps/konstrukt && npm run build