Text Styling Default Options
Text transformation samples (strikethrough, underline, kerning, baseline offset).
SwiftUI Implementation
Pure Vanilla Swift • No DependenciestextStylingDefaultOptions.swift
struct TextStylingDefaultOptions: View {
@State private var isBold: Bool = true
@State private var isItalic: Bool = true
@State private var strike: Bool = true
@State private var underline: Bool = true
@State private var isMonospaced: Bool = true
var body: some View {
ScrollView {
VStack(spacing: 8) {
VStack(spacing: 8) {
Text("Text with .foregroundStyle(.foreground)")
.foregroundStyle(.foreground)
Text("Text with .bold()")
.bold()
Text("Text in bold based on state value")
.bold(isBold)
Text("Text with .italic()")
.italic()
Text("Text in italic based on state value")
.italic(isItalic)
Text("Text with .strikethrough()")
.strikethrough()
Text("Strike based on state value")
.strikethrough(strike, color: .red)
Text("Dash strike pattern")
.strikethrough(strike, pattern: .dash, color: .red)
Text("DashDot strike pattern")
.strikethrough(strike, pattern: .dashDot, color: .red)
Text("DashDotDot strike pattern")
.strikethrough(strike, pattern: .dashDotDot, color: .red)
}
VStack(spacing: 8) {
Text("Dot strike pattern")
.strikethrough(strike, pattern: .dot, color: .red)
Text("Solid strike pattern")
.strikethrough(strike, pattern: .solid, color: .red)
Text("Text with underline")
.underline()
Text("Underline based on state value")
.underline(underline)
Text("Underline based on state value")
.underline(underline, color: .red)
Text("Dash underline")
.underline(underline, pattern: .dash, color: .red)
Text("DashDot underline")
.underline(underline, pattern: .dashDot, color: .red)
Text("DashDotDot underline")
.underline(underline, pattern: .dashDotDot, color: .red)
Text("Dot underline")
.underline(underline, pattern: .dot, color: .red)
Text("Solid underline")
.underline(underline, pattern: .solid, color: .red)
}
VStack(spacing: 8) {
Text("Monospaced")
.monospaced()
Text("Monospaced based on state value")
.monospaced(isMonospaced)
Text("MonospacedDigit")
.monospacedDigit()
Text("Text with custom kerning")
.kerning(5.0)
Text("Text with custom tracking")
.tracking(4.0)
Text("Text with custom baseline offset")
.baselineOffset(10.0)
Text("Text Uppercased")
.textCase(.uppercase)
Text("Text Lowercased")
.textCase(.lowercase)
}
}
.font(.system(size: 15))
}
}
}
#Preview {
TextStylingDefaultOptions()
}Ready to copy and paste directly into any Xcode project running iOS 16.0+.
Recommended Use Cases
- App settings, preferences, and account configuration screens
Component Details
- Category
- Texts & Typography
- iOS Compatibility
- iOS 16.0+
- Xcode Version
- Xcode 15+
- Platform
- iOS
- License Tier
- Free
- Themes & Contexts
- settings
C
Compot for iOS
Native SwiftUI playground app
Preview all 130+ components interactively on your device and copy code straight to Xcode with 1 tap.
Get Compot on the App StoreRelated SwiftUI Components
More components in Texts & Typography and related app architectures.
ButtonsiOS 16.0+
Button for Copying
Smart copy button that temporarily switches icon and text to "Copied!" with tactile haptic feedback.
View Component & Code
ButtonsiOS 16.0+
Bordered Green Rounded Button (Regular)
Standard-sized bordered button with custom green tint and continuous rounded corners.
View Component & Code
ButtonsiOS 16.0+
Bordered Green Rounded Button (Mini)
Compact mini bordered button for tight layouts, list items, and secondary badges.
View Component & Code