This skill guides building extensible SwiftUI style-driven components using Apple patterns like ButtonStyle and LabelStyle, enabling environment-based styling
npx playbooks add skill ahmadbrkt/swiftui-style-driven-components-skill --skill swiftui-style-driven-components
This skill provides expert guidance on building, reviewing, and extending SwiftUI components following the style-driven architecture pattern. This pattern emphasizes extensibility, maintainability, and Apple-style API design, making it ideal for building reusable component libraries.
ButtonStyle, LabelStyle) as the gold standard.LabelStyleConfiguration.Title).public.style.makeBody in AnyView for type erasure.DynamicProperty for style protocols, not Sendable.any [Component]Style).[Component]Style — defines HOW to render[Component]StyleConfiguration — contains WHAT to renderUse style protocol when:
@Environment)Skip style protocol when:
references/component-structure.mdreferences/style-protocol.mdreferences/environment-keys.mdreferences/common-patterns.md[Component]StylemakeBody(configuration:).myStyle)DynamicProperty, @ViewBuilder @MainActorinternalstyle.makeBody in AnyViewany [Component]Style)references/component-structure.mdreferences/style-protocol.mdreferences/style-protocol.mdreferences/environment-keys.mdreferences/common-patterns.mdreferences/common-patterns.mdreferences/documentation.mdreferences/design-system.mdreferences/testing.mdreferences/previews.mdreferences/accessibility.mdreferences/advanced-patterns.md[Component]/
├── EnvironmentKeys/[Component]StyleKey.swift
├── Styles/
│ ├── [Component]Style.swift
│ ├── [Component]StyleConfiguration.swift
│ └── Default[Component]Style.swift
└── [Component].swift
DynamicProperty, @ViewBuilder @MainActor func makeBodystruct Content: View with private let _body: () -> AnyViewinternal (not public), @MainActorAnyView(style.makeBody(configuration: .init(...)))@Entry public var style: any [Component]Style = .automaticfunc style(_ style: some [Component]Style) -> some ViewDynamicProperty for style protocolsinternalstyle.makeBody in AnyView.compact, .outlined)Sendable to style protocolspublicAnyView directly as configuration property typeforegroundColor() (deprecated — use foregroundStyle()).cornerRadius() (deprecated — use clipShape())DynamicPropertymakeBody has @ViewBuilder @MainActorinternalstyle.makeBody in AnyView@Entry macroany [Component]Style)some [Component]Style).automatic)/// doc commentsreferences/previews.md)references/testing.md)references/accessibility.md)references/design-system.md)references/component-structure.md — File organization, MARK conventionsreferences/documentation.md — Doc comments following Apple conventionsreferences/style-protocol.md — Protocol, configuration, anti-patternsreferences/environment-keys.md — Environment injection, usage patternsreferences/common-patterns.md — Convenience inits, parameterized styles, bindings, rolesreferences/advanced-patterns.md — State machines, dual protocols, result buildersreferences/testing.md — Snapshots, config tests, test helpersreferences/previews.md — Preview structure, stateful helpers, snapshot mappingreferences/design-system.md — Design tokens, typography, colorsreferences/accessibility.md — Labels, identifiers, Dynamic TypeStyle-driven components prioritize:
ButtonStyle, LabelStyle conventionsWeekly roundup of top Claude Code skills, MCP servers, and AI coding tips.