JordanCoin/ios-skills-collection / skills/daetojemax--figma-to-swiftui-skill
figma-to-swiftui
VerifiedTranslate Figma designs into production-ready SwiftUI code with 1:1 visual fidelity using the Figma MCP workflow. Trigger when the user provides Figma URLs or node IDs and wants iOS/SwiftUI implementation, asks to implement a design or component from Figma for an iOS app, or references Figma selections in the context of an Xcode/SwiftUI project. Also trigger when user asks to inspect Figma designs for iOS planning, fetch design tokens for SwiftUI, or convert Figma assets for Xcode. Requires a working Figma MCP server connection. Do NOT trigger for web/React implementations.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 15.9 KB |
| references/adaptation-workflow.md | markdown | 4.0 KB |
| references/asset-handling.md | markdown | 6.2 KB |
| references/component-variants.md | markdown | 8.1 KB |
| references/design-token-mapping.md | markdown | 3.7 KB |
| references/figma-mcp-setup.md | markdown | 935 B |
| references/layout-translation.md | markdown | 3.9 KB |
| references/responsive-layout.md | markdown | 5.0 KB |
references/responsive-layout.md
View on GitHub# Figma to Responsive SwiftUI Layout
How to translate device-specific Figma frames into adaptive SwiftUI views. Complements layout-translation.md (which covers 1:1 Auto Layout mapping) with multi-device adaptation.
## When to Ask About Device Support
- Figma frame width 375–430pt (iPhone range) and the project's deployment target includes iPad → ask the user if iPad adaptation is needed before implementing
- Figma contains multiple frames for different devices (iPhone + iPad) → fetch all frames via get_design_context + get_screenshot, then ask the user how to combine them
- Figma frame width 744–1024pt (iPad range) only → ask if iPhone support is needed
- Do not assume. Always confirm device scope with the user.
## Figma Fixed Values → Adaptive SwiftUI
Figma designs use absolute pixel values. Not all of them should become fixed frames in SwiftUI.
**Full-screen width (375, 390, 393, 430)**
→ `.frame(maxWidth: .infinity)`, never `.frame(width: 375)`
**Fixed-size elements (icons, avatars, badges)**
→ Keep `.frame(width:, height:)` — these are intentionally fixed
**Content containers with fixed width**
→ Replace with relative sizing. Use `containerRelativeFrame` (iOS 17+) or `GeometryReader` for proportional widths:
```swift
// Figma: card width 343 in 375pt frame (91.5% of screen)
.containerRelativeFrame(.horizontal) { length, _ in
length * 0.915
}
```
**Banned: `UIScreen.main.bounds`**
→ Always use `containerRelativeFrame` (iOS 17+) or `GeometryReader`. Screen bounds breaks in Split View, Slide Over, and Stage Manager.
## Size Classes for Layout Switching
Use `@Environment(\.horizontalSizeClass)` when Figma shows fundamentally different layouts per device (not just wider spacing).
- compact = iPhone portrait, iPad split/slide-over
- regular = iPad full-screen, iPhone landscape (some models)
```swift
struct ContentView: View {
@Environment(\.horizontalSizeClass) private var sizeClass
var body: some View {
if sizeClass == .compact {
NavigationStack {
ItemList()
}
} else {
NavigationSplitView {
ItemList()
} detail: {
ItemDetail()
}
}
}
}
```
When to use size classes:
- Figma shows list (iPhone) vs grid (iPad) → switch layout
- Figma shows single column (iPhone) vs sidebar + content (iPad) → NavigationSplitView
- Figma shows stacked sections (iPhone) vs side-by-side (iPad) → switch between VStack and HStack
When NOT to use size classes:
- Same layout, just wider → use flexible frames and `.infinity`, no branching needed
## Merging iPhone + iPad Figma Frames
When Figma provides separate frames for iPhone and iPad:
1. Fetch both frames via get_design_context + get_screenshot
2. Identify shared components (same content, same structure) → extract into shared views
3. Identify differences (layout changes, visibility changes, different arrangements)
4. Implement one SwiftUI view that switches on `horizontalSizeClass`
```swift
struct ProfileView: View {
@Environment(\.horizontalSizeClass) private var sizeClass
var body: some View {
if sizeClass == .compact {
// iPhone layout: vertical stack
ScrollView {
VStack(spacing: 16) {
ProfileHeader()
ProfileStats()
ProfileContent()
}
}
} else {
// iPad layout: side-by-side
HStack(alignment: .top, spacing: 24) {
VStack {
ProfileHeader()
ProfileStats()
}
.frame(width: 320)
ProfileContent()
.frame(maxWidth: .infinity)
}
}
}
}
```
## ViewThatFits (iOS 16+)
Use when Figma shows two layout variants (e.g. horizontal and vertical) without tying them to specific devices. SwiftUI picks the first variant that fits the available space.
```swift
ViewThatFits(in: .horizontal) {
// Try horizontal first
HStack(spacing: 12) {
icon
label
Spacer()
value
}
// Fall back to vertical
VStack(alignment: .leading, spacing: 8) {
HStack(spacing: 12) { icon; label }
value
}
}
```
Best for: action bars, label+value pairs, tag rows — anywhere content may or may not fit in one line.
## Common Figma → Responsive Patterns
| Figma Design | SwiftUI Implementation |
|---|---|
| Sidebar + content (iPad) | `NavigationSplitView` |
| 2-col grid (iPad) → 1-col (iPhone) | `LazyVGrid` with adaptive columns: `GridItem(.adaptive(minimum: 160))` |
| Full-width card (iPhone) + constrained card (iPad) | `.frame(maxWidth: 600)` with `.frame(maxWidth: .infinity)` parent for centering |
| Horizontal tabs (iPad) → bottom tab bar (iPhone) | `TabView` (system handles placement) or switch on sizeClass |
| Wide form fields (iPad) → full-width (iPhone) | `.frame(maxWidth: 500)` centered in container |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |