If you’re an iOS developer who knows Swift but is just starting out with SwiftUI, you’ve probably come across two views that seem similar: Text and Label. At first glance, they both put words on the screen. So what’s the real difference? And when should you use one over the other?
Let’s break it down step by step.
What is Text in SwiftUI?
Think of Text as the most basic way to show words on the screen.
It’s lightweight, flexible, and works well for titles, paragraphs, or captions.
Text("Hello, World!")
.font(.title)
.foregroundColor(.blue)👉 This displays just the words Hello, World!, styled as a title in blue.
In UIKit terms:
Textis likeUILabel.- It’s plain text, nothing else.
What is Label in SwiftUI?
Label is like an upgrade to Text. It combines text + icon into a single view.
Label("Settings", systemImage: "gear")👉 This shows a gear icon followed by the word Settings.
In UIKit terms:
Labelis like writing anHStackwith anUIImageViewand aUILabel.- But in SwiftUI, it’s cleaner and comes with accessibility built in.
Why Not Just Use HStack (Image + Text)?
HStack {
Image(systemName: "gear")
Text("Settings")
}It will look the same on screen.
But here’s the issue: VoiceOver accessibility.
- The HStack version may read as “gear, Settings” (confusing).
- The
Labelversion simply reads as “Settings” (much better).
So Label is not just shorter code — it’s also more user-friendly.
Label Styles
SwiftUI lets you control how labels appear depending on context:
Label("Settings", systemImage: "gear")
.labelStyle(.titleOnly) // Only the text
.labelStyle(.iconOnly) // Only the icon
.labelStyle(.automatic) // Both (default)This is super handy in toolbars or compact layouts where space is tight.
Text vs Label: Quick Comparison
| Feature | Text | Label |
|---|---|---|
| Shows text | ✔️ | ✔️ |
| Shows image | ❌ | ✔️ |
| Accessibility | Reads text only | Reads text (ignores icon name) |
| UIKit analogy | UILabel | UIImageView + UILabel |
| Use case | Titles, paragraphs, captions | Buttons, menus, toolbars, lists |
Final Thoughts
If you’re moving from UIKit to SwiftUI, think of Text as your UILabel replacement and Label as the SwiftUI-friendly way of combining text with an icon.
Text= plain words.Label= icon + words, with accessibility baked in.
Mastering this small distinction will make your SwiftUI code more readable, accessible, and future-proof.
So next time you’re building a toolbar, list, or menu item, reach for Label. And when you just need text? Stick with Text.
