StudioKit
StudioKit is the SwiftUI implementation of the Studio design system for iPhone, iPad and Mac (iOS 18+, macOS 15+). This tree implements Studio 2.1 (StudioRelease.version, which a test keeps equal to tokens.json's release); the package's own version is set at release. It is a Swift package, built in the Swift 6 language mode. Every value comes from packages/system/DESIGN.md through the generated Sources/StudioKit/Generated/StudioTokens.swift.
Status: written and syntax-checked, not compiled. No Swift toolchain runs where this release was made. Each file passes two checks:
node tools/swift-syntax.mjs, a tree-sitter parse that also checks token names.- A symbol cross-check,
node packages/swift/scripts/swift-symbols.mjs: everyStudioColor.x,StudioSpace.x,StudioComponent.X.yand.studioText(.role)must exist in the generated file.
Neither check proves the code builds. Run swift build and swift test --package-path packages/swift before you depend on it. The risks are listed under Open items.
import StudioKit
@main struct StudioApp: App {
init() { StudioFonts.register() }
var body: some Scene {
WindowGroup {
ContentView()
.studioToasts() // one toast centre per window
.studioTheme(appearance: .system, density: .airy)
}
}
}
StudioCard {
StudioKicker("Create")
StudioTwoToneTitle("Start something ", accent: "new.", role: .headlineMd)
StudioButton("New", systemImage: "plus", variant: .primary) { create() }
}
The full public API, with every initialiser, is in the API list below and in the Xcode Quick Help.
What is generated
| Path | Source | Edit? |
|---|---|---|
Sources/StudioKit/Generated/StudioTokens.swift | npm run tokens from packages/system/DESIGN.md | Never |
Sources/StudioKit/Resources/Fonts/ | node tools/sync-fonts.mjs from packages/system/fonts/ | Never |
Tests/StudioKitTests/Resources/tokens.json | tools/sync-package.mjs from packages/system/dist/tokens.json | Never |
Tests/StudioKitTests/TokenTable.swift | node packages/swift/scripts/token-table.mjs (every tokens.json key beside its Swift symbol; --check for drift) | Regenerate when keys change; the count tests fail until you do |
Everything else in Sources/ and Tests/ | Hand-written | Yes |
Token names follow the generator's rule, with the spec key in lowerCamelCase under its group. For example, StudioColor.onSurface2, StudioSpace.s3h, StudioThreshold.rowFoldAt and StudioComponent.ListRow.height. The full list is in DESIGN.md, in the Platform mapping section.
Components
Each public view reads the spec keys beside it and nothing else. The names follow the spec's Build names table.
| StudioKit | Spec keys | Notes |
|---|---|---|
View.studioText(_:), StudioTypeRole.* | typography.*, type-transform | Every role, plus .kicker, .label, .meta |
StudioTwoToneTitle | accent-word, headline-* | One Text, so both faces wrap together |
StudioKicker | kicker, kicker-dot, page-kicker, section-kicker | |
StudioTheme (\.studioTheme), StudioAppearance, StudioDensityMode | data-theme, data-density, data-contrast, data-transparency, density | The density enum is StudioDensityMode because the generator uses StudioDensity for the overrides |
StudioFrame, StudioPresentation, StudioSwitcher, StudioLadder, StudioRegion | content-max, gutter*, band*, pageMdAt/pageLgAt, regions, ladder, resolve, switcher | |
View.studioGlass, StudioGlassGroup | glass, glass-solid, glass-rim, glass-highlight, materials.glass | |
View.studioBorder, View.studioShadow, StudioDivider | spacing.hairline, elevation.*, divider* | |
StudioButton, StudioButtonStyle (.studio(_:)) | button*, button-sm, button-lg | |
StudioIconButton | button-icon*, toolbar-icon, nav-icon-on | |
StudioFabButton, StudioFabStyle (.studioFab(isPrimary:)) | fab, fab-primary, button-primary-hover, button-primary-active, button-primary-disabled | A 56pt floating circle. The style also fits a ShareLink or Menu label. Since 2.1 the Studio app uses the system tab bar instead; kept for other consumers |
StudioDock, StudioDockItem | dock, dock-item, dock-item-current | A glass tool pill. Text is capped at the largest non-accessibility size, and the large content viewer is on. The Studio app's page editor uses it on iPhone (Insert · Style · Preview) |
StudioSegmented, StudioSegment | segmented* | |
StudioField | field*, textarea | onBlur runs when focus leaves, for validation on blur |
StudioInputPill, StudioInputGroup, StudioDomainPicker | input-pill*, field-invalid, field-error, input-group, domain-picker, domain-globe | StudioInputPill(error:) sets the invalid rim and the message |
StudioSwatchPicker, StudioSwatch | swatch, swatch-selected, field-label | 32pt circles in 44pt targets. They wrap when the container is narrow |
StudioSearchField | search-field* | |
StudioToggleRow | toggle-track* | |
StudioChip, StudioPlanChip, StudioBadge | chip*, plan-chip, badge | |
StudioKindBadge, StudioKind, StudioKindTone, StudioSaveModel, StudioKindViewControl | kind-badge, kind-dot-*, colors.kind-* | The nine kinds (studio-react KINDS) in the New sheet's order with the spec's ids: label, plural, short word, blurb, glyph, tone (four colour families), metric, primary action, save model, view control, address. 2.1's site decodes as .biopage (init(storedValue:)) |
StudioDeltaPill | delta-pill* | |
StudioStatusDot, StudioStatusLabel, StudioStatus | status-dot*, status-*, materials.status-halo | DESIGN.md's one vocabulary, the same as studio-react's Status: Live, Paused, Draft, Failed, and the Editing dot. Local or sample data never shows Live |
StudioSaveStateLabel, StudioSaveState | save-state, save-state-failed, status-dot* | Saved, Saving, Unsaved, Offline, Failed. Only Failed is prominent, with an optional Retry |
StudioCard | card, card-feature | |
StudioCreateTile, StudioIconWell | create-tile*, icon-well*, card-title, card-blurb | |
StudioCallout | callout* | onDismiss adds a close circle for a banner the reader may close |
StudioSectionHeader, StudioCapsLink | section-header, section-kicker, caps-link* | |
StudioPageHead, StudioFact | page-head, page-lead, page-kicker, fact, fact-label | |
StudioStatTile | stat-tile*, stat-label, stat-sub | |
StudioListRow, StudioThumb | list-row*, list-row-thumb-*, separator-dot, button-icon-sm | |
StudioSparkline | sparkline* | Swift Charts; height defaults to spark-h |
StudioAreaChart, StudioLegendItem, StudioSeriesPalette | chart*, legend-*, chart-series-* | |
StudioRankRow | rank-bar* | |
StudioAvatar | avatar* | |
StudioBrandMark | nav-brand-mark | |
StudioMenu, StudioMenuItem, StudioMenuLabel, StudioMenuSeparator | menu* | |
StudioAccountMenu | account-menu, menu-header*, plan-chip, segmented | |
StudioToast, StudioToastCenter, View.studioToasts(_:), View.studioToasts(), View.studioBottomChrome(isActive:) | toast*, motion.toast-* | studioToasts() gives a window its own centre. The lane sits s-4 above the bottom safe area, or s-2 above bottom chrome that publishes its height with .studioBottomChrome() (the narrow-navigation circles, the dock), as DESIGN.md's "above the dock" asks |
View.studioConfirm, StudioModal | modal* | |
StudioSheet, View.studioSheetPresentation | sheet* | |
StudioToolbar (View.studioToolbar), StudioToolbarPill | toolbar*, brand-pill, toolbar-pill | |
StudioEmptyState | empty-state* | |
View.studioSkeleton | skeleton | |
StudioCanvas | canvas | |
StudioPanelSection | panel-section, panel-section-label | An inspector group. Separate neighbours with StudioDivider(soft: true) |
StudioPlaceholderArt | template-art, colors.kind-*-surface, primary-soft | A geometric stand-in for a missing image. The spec's artwork palette isn't generated for Swift, so it uses the kind tints |
StudioMeasure | measure* | ch measures, which the generator does not emit |
StudioHomeHero, StudioHeroStat | home-hero, home-hero-compact, home-hero-lead, hero-stats, hero-stat-card, hero-stat-label | Home's greeting, lead and three stats: a column at the end from tabbar-at, a 3-up row of cards below it that never wraps |
StudioKindTile | kind-tile, kind-tile-blurb, kind-tile-hover | A kind to start (Home's 2×2, the New sheet) |
StudioComposer | composer | The paste-a-URL feature card; the host puts the fields and the lime Shorten in it |
StudioLookCard | look-card, look-card-hover | A template in "Start from a look" |
StudioEditorWorkspace, StudioEditorPane, StudioEditorPaneLabels, StudioEditorSheetBar | editor-workspace, library-panel, editor-canvas, inspector-panel (the system inspector), editor-sheetbar, editor-sheetbar-item, editor-sheet-at, library-collapse-at, editor-panel-w, editor-panel-w-wide | One editor for every kind: library panel (glass, collapsible), canvas, .inspector; below editor-sheet-at, sheets from a glass bar (Library · Preview · Settings, or Blocks · Page · Settings) |
StudioEditorTitleLabel, StudioZoomControl | editor-pill, editor-pill-kind | The editor bar's kind-and-name menu label; the QR zoom (50–200% in quarters, adjustable for VoiceOver) |
StudioLibraryTile, StudioLibraryRow | library-tile, library-tile-current, library-tile-hover, resource-row-compact | The library's New tiles and Recently edited rows |
StudioInspectorSection, StudioMoreOptions | inspector-section, more-options | An inspector group outside a Form; the one collapsed More options with its hint |
StudioEventCard, StudioFileCard, StudioSplashPreview, StudioCheckoutCard, StudioStaticFrame | event-card, file-card, splash-preview, checkout-card, static-frame | What a visitor gets, on the canvas. StudioStaticFrame is a WKWebView with JavaScript off, navigation blocked and Cardsite's CSP prepended (sandboxed(_:)); drawn buttons are hidden from VoiceOver |
StudioResultsLine | results-line | The quiet count under a collection's toolbar, with an optional Clear filters |
StudioAddressField | address-field, field-label, field-invalid, field-focus | Domain menu, "/", the slug in mono-md and Copy in one pill; error and onBlur as StudioField |
StudioShareCard | share-card | The preview of what is shared: kicker, title, address in mono, detail, an optional thumbnail and a row of actions |
StudioObjectHead, StudioTypeCard, StudioSectionLabel | object-head, object-head-type, panel-section-label | The heads of an editor: the icon well, the name edited in place with the kind as its serif accent word, a mono-caps caption of facts and a trailing control (the Active switch); the inspector's read-only type card; the mono-caps label over a group of fields, with an optional readout. The caption and label are uppercase, so never a sentence, an email or a URL |
StudioDropIndicator | drop-indicator | The primary-line rule where a dragged block lands |
StudioBlockToolbar, StudioBlockHandle | block-toolbar, block-handle | The selected block's floating glass pill, and its 24pt grip in a 44pt target |
StudioPaletteItem | palette-item, palette-item-hover | A page-editor widget label; the caller makes it a Button and .draggable |
Every gallery has a #Preview in light and in dark, in Sources/StudioKit/Previews/StudioPreviews.swift; the editor heads have theirs in Sources/StudioKit/Surfaces/StudioObjectHead.swift.
Liquid Glass
Glass belongs on functional chrome and never on content. This follows the HIG ("Don't use Liquid Glass in the content layer") and DESIGN.md's Apple platforms section.
- The system draws the bars. Navigation bars, toolbars, tab bars, sidebars, inspectors, sheets, popovers and menus all come from the system. On OS 26+ they are already glass. StudioKit sets no bar backgrounds, and
StudioToolbaronly places items. - Studio's own floating chrome uses
.studioGlass. That chrome is the toast,StudioToolbarPill,StudioDock, the menuStudioFabButton,StudioIconButton(isGlass: true)for canvas tools, and the editor workspace's library panel and narrow sheet bar. Group neighbouring pieces inStudioGlassGroup. - Content never takes glass. Cards, rows, tiles, stat tiles, charts, fields, the canvas, a sheet's body and dialogs all use
surfacewith a hairline. - The primary action is an opaque lime capsule (or the lime
StudioFabButton(isPrimary: true)circle), soon-primaryink keeps its contrast. Glass is never tinted lime. - The glass renders in one of three ways:
| Condition | Rendering | |---|---| | OS 26+ | glassEffect(.regular), interactive on controls | | Earlier OS | .regularMaterial, the spec's 90% glass fill, the glass-line rim, the lit top edge and the float shadow | | Reduce Transparency or Increase Contrast | Opaque glass-solid with its rim |
Materials/StudioGlass.swiftis the only file that branches on the OS version.
Accessibility
| Setting | StudioKit's response |
|---|---|
| Dynamic Type | Every role scales with its text style through UIFontMetrics, so 9pt captions grow too. Fixed layouts reflow at accessibility sizes: section headers stack, stat-tile deltas drop a line, list rows fold, and the page head's facts become tiles |
| Bold Text | Every role moves one weight step heavier |
| VoiceOver | Icon-only controls require a label. Rows and stat tiles read as one element. Toggled and selected states carry .isSelected. The two-tone title is a header. Delta pills speak "Up 8.2%". Toasts are announced. Charts keep Swift Charts' chart navigation, and decorative sparklines are hidden |
| Increase Contrast | Hairlines become 1pt outline-strong, muted ink (.studioMuted) becomes on-surface-2, and glass becomes opaque |
| Reduce Transparency | Glass becomes opaque glass-solid with its rim |
| Reduce Motion | No press scale, no sliding selection, no toast drop and no hover nudges. Changes apply at once |
| Hit targets | Every control's tappable area is at least 44pt (studioHitTarget), whatever its drawn size, on every platform |
| Keyboard | Controls are native Button, TextField, Toggle and Menu, so focus and Full Keyboard Access are the system's. Escape clears the search field, and the modal and sheet close buttons take .cancelAction |
| Colour alone | Kinds carry a glyph or a name, statuses carry a word, deltas carry an arrow and a sign, and chart comparison lines are dashed |
Line height
The spec writes line height the CSS way: the total line box as a multiple of the size. SwiftUI's lineSpacing adds space on top of the font's natural line height. StudioKit 1.x first applied size × (lineHeight − 1), which counted the natural leading twice. 2.0 measures the actual Core Text font and applies:
spacing = max(0, size × lineHeight − (ascent + descent + leading))
Display roles at 1.0 resolve to zero. SwiftUI can't set lines tighter than the font's own height, so multi-line display headlines run slightly looser than on the web. That difference is accepted.
Migrating from 1.x
2.0 is a rewrite on the new spec, with a new visual language. It is not a reskin. The things that changed:
| 1.x | 2.0 |
|---|---|
swift-tools-version: 5.9, iOS 17, macOS 14 | Tools 6.0 (Swift 6 mode), iOS 18, macOS 15 |
| Certia and Editorial New fonts | Bounded, Instrument Serif, Inter Tight and JetBrains Mono. StudioFonts.register() is unchanged |
Color.studioText, Color.studioAccent, Color.StudioPalette.* | StudioColor.onSurface, StudioColor.primary, and so on. There is no raw palette; views use roles |
| 1.x colours were light-only on macOS | Every colour resolves light and dark on both platforms |
StudioSpace.s5 (20pt) as the card padding | StudioCard pads with card.padding, which is 16pt (s-4), or 24pt for .feature |
StudioTextStyle cases (.display, .title, .body, .ui, .mono…) | StudioTypeRole (StudioType.*). The old names remain as deprecated statics that point to the new role. StudioTextStyle is now the Dynamic Type anchor enum |
.studioText(.kicker / .label / .meta) | Kept, still uppercase captions: kicker = caption-md, label = caption-md, meta = caption-xs. Still never for sentences, emails or URLs |
.studioMuted() modifier | .foregroundStyle(.studioMuted), which follows Increase Contrast |
StudioCard(flush:radius:) | StudioCard(_ variant:isPadded:spacing:). flush: true becomes isPadded: false; the radius comes from the variant |
StudioTextField | StudioField (the spec's build name). StudioTextField remains as a deprecated typealias |
StudioViewport bands (720 / 1100) | No device bands. Thresholds are measured on containers (StudioThreshold.*, StudioLadder, StudioFrame) |
StudioAppShell, StudioTopbar, StudioDock, StudioEditorShell, StudioCollectionBar | Removed. Use system containers: NavigationSplitView, TabView(.sidebarAdaptable), .toolbar with studioToolbar, .inspector, .searchable. 2.0's StudioDock is a different, smaller component: the editor's tool pill at compact width, with StudioDockItems |
.studioGlass(cornerRadius:tint:interactive:) | .studioGlass(in:interactive:). There is no tint, because glass is never tinted |
StudioGlassContainer, .studioGlassMorph | StudioGlassGroup, .studioGlassID |
StudioElevation enum (.flat, .raised) with .studioElevation | Generated StudioElevation.<tier> (StudioShadowSet) with .studioShadow(_:) |
StudioToastCenter(duration:), .show(_:variant:) | StudioToastCenter(autoDismiss:announce:), .show(_:tone:action:), with the spec's durations, a limit of three, pause on hover and focus, and a VoiceOver announcement. Prefer .studioToasts() per window to one centre at the App level, and mark bottom chrome with .studioBottomChrome() so toasts never cover it |
StudioStatusPill, StudioBanner, StudioTone | StudioStatusLabel and StudioStatus; StudioCallout and StudioCalloutTone |
StudioConfirmDialog, .studioConfirm(item:…) | .studioConfirm(_:isPresented:message:confirmTitle:isDestructive:onConfirm:) on the system dialog, or StudioModal |
StudioHaptics | Removed. Use .sensoryFeedback |
Studio 2.1 additions
2.1 adds parts and changes nothing that exists, so 2.0 code builds unchanged:
| Change | Notes |
|---|---|
New: StudioTodayCard, StudioTodayFigure, StudioAttentionRow, StudioResultsLine, StudioAddressField, StudioShareCard, StudioDropIndicator, StudioBlockToolbar, StudioBlockHandle, StudioPaletteItem (Surfaces/StudioWorkspace.swift) | The content of the app shell and the two editing models. The shell itself is the system's: NavigationSplitView with a sidebar on iPad and Mac, TabView on iPhone, .toolbar, .searchable, .sheet; StudioKit adds no shell type |
StudioCallout(…, onDismiss:) | Optional; nil keeps 2.0's callout |
StudioSparkline(…, height:) | Optional; defaults to spark-h |
StudioRelease.version is "2.4.0" | Follows tokens.json |
The new tokens (sidebar-w, drawer-w-wide, today-spark-h, collection-compact-at, the shell, collection, drawer and editor components, the code roles) | Generated into StudioTokens.swift; StudioSpace.drawerW is now 480 (was 300) |
Open items
These are the first places to look when this package is compiled:
- Swift 6 isolation with tools 6.0. The package is nonisolated by default. These pieces must build under strict checking:
StudioMutedInk.resolve(in:), a nonisolatedShapeStylethat readsEnvironmentValues.StudioToast.Action's@MainActor @Sendablehandler.- The
Tasktimers inStudioToastCenter. .studioBottomChrome(), which reads an optional@Environment(StudioToastCenter.self)and reports throughonGeometryChange. Check that the first height arrives before the first toast, and that the toast lane drops back when the chrome disappears.- Fonts and variable weight. Bounded's weight is applied on the
wghtaxis throughkCTFontVariationAttribute, andFont(CTFont)is used for every role. Check two things: thatFont(ctFont)keeps the variation, and that.trackingand.lineSpacingapply to it. Also checkStudioFonts.failures(a test asserts it is empty). - Dynamic Type mapping.
UIFontMetrics.scaledValue(for:compatibleWith:)is called with a trait collection built fromDynamicTypeSize. Check that text sizes track the system's at accessibility sizes. - Swift Charts. Check these calls in
StudioCharts.swift: AreaMark(x:yStart:yEnd:).fontand.foregroundStyleonAxisValueLabelandAxisGridLinechartYScale(domain:)with aClosedRange<Double>- Menus with custom labels. Check that
Menuwith.menuStyle(.button)+.buttonStyle(.plain)+.menuIndicator(.hidden)keeps the domain picker's and the row overflow's custom label on macOS. ViewThatFitsin stat tiles and section headers. Check that the label falls back to its own line before it truncates, at 390pt and at accessibility sizes.StudioMenuin a.popover. The width is fixed at 272pt. Check that it adapts when the popover becomes a sheet on iPhone.- The narrow-navigation and editor parts. Check these:
.studioFab(isPrimary:)on aShareLinkand aMenulabel, on both platforms.accessibilityShowsLargeContentViewer()and.dynamicTypeSize(...DynamicTypeSize.xxxLarge)onStudioDockon macOS. Both are iOS 15 and macOS 12 API but aren't in the job's verified list.StudioField(onBlur:), which usesonChange(of: isFocused). Check that it fires on Tab, on a click elsewhere, and when the inspector sheet closes.studioHitTargetadds layout height (a 30pt chip lays out 44pt tall). This is the spec's rule ("44pt whatever its visible size"), but it changes spacing compared with the web. Check dense rows.- The 2.1 parts. Check that
StudioAddressField's domainMenuwith a custom label keeps its look on macOS (as item 5), thatStudioBlockToolbar's glass reads over canvas text on OS 26, and thatStudioTodayCard'sminimumScaleFactorkeeps the 3-up row on one line at accessibility sizes.
API at a glance
Foundations:
StudioFonts.register().studioText(_:scaled:)Font.studio(_:)StudioTwoToneTitleStudioKicker.studioTheme(appearance:density:).studioDensity(_:)\.studioTheme.studioMutedStudioFrameStudioSwitcherStudioLadder.resolve(width:regions:).studioHitTarget(visualHeight:).studioBorder(_:color:emphasis:).studioShadow(_:).studioGlass(in:interactive:)
The components are listed in the Components table. Each type's initialisers are documented in its source file.