Snippets
SwiftUI foregroundStyle and tint
Prefer foregroundStyle and tint for modern SwiftUI color styling, especially when controls, symbols, gradients, and semantic materials mix.
4 min readUpdated 2026-06
import SwiftUI
struct SyncStatus: View {
var body: some View {
Label("Synced", systemImage: "checkmark.circle.fill")
.font(.subheadline.weight(.medium))
.foregroundStyle(.green)
.padding(.horizontal, 10)
.padding(.vertical, 6)
.background(.green.opacity(0.12), in: Capsule())
.tint(.green)
}
}Implementation notes
foregroundStyle accepts ShapeStyle values, so it works with colors, gradients, and materials.
tint is the modern way to influence many controls without reaching for deprecated accentColor patterns.
Inherited color can be useful, but be explicit around destructive, success, and warning states.
Checklist
Check contrast in both color schemes.
Use semantic names in your design system for repeated meanings.
Avoid using color alone to communicate state.
Related reference
SwiftUI Gradients and ShapeStyle
Choose linear, radial, angular, image, and mesh-style fills based on the job the color is doing in the interface.
SwiftUI Image Resizing and SF Symbols
Resize bitmap images and SF Symbols predictably by separating intrinsic image behavior, content mode, and symbol styling.
SwiftUI Toolbar and ControlGroup Actions
Place primary and secondary commands in toolbars with predictable placement, grouping, tinting, and keyboard-aware behavior.