Text Editor Simple
Clean multi-line TextEditor with standard border styling.
SwiftUI Implementation
Pure Vanilla Swift • No DependenciestextEditorSimple.swift
import SwiftUI
struct TextEditorSimple: View {
@State private var text: String = ""
@FocusState private var focusText: Bool
var body: some View {
VStack(alignment: .leading, spacing: 4) {
Text("Text Editor")
.font(.callout)
.foregroundStyle(.secondary)
.font(.system(size: 15, weight: .regular, design: .default))
TextEditor(text: $text)
.focused($focusText)
.autocorrectionDisabled()
.textSelection(.enabled)
.padding(.horizontal, 8)
.padding(.vertical, 4)
.foregroundStyle(.primary)
.font(.system(size: 15, weight: .regular, design: .default))
.lineSpacing(2)
.overlay(RoundedRectangle(cornerRadius: 8).stroke(Color(uiColor: .tertiarySystemFill), lineWidth: 1.5))
}
.padding()
.frame(maxWidth: .infinity, maxHeight: 150)
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Spacer()
Button("Hide keyboard") {
focusText = false
}
}
}
}
}
#Preview {
TextEditorSimple()
}Ready to copy and paste directly into any Xcode project running iOS 16.0+.
Recommended Use Cases
- Dashboard overviews, stats tracking, and metric highlights
Component Details
- Category
- Inputs & Text Editors
- iOS Compatibility
- iOS 16.0+
- Xcode Version
- Xcode 15+
- Platform
- iOS
- License Tier
- Free
- Themes & Contexts
- dashboard
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 Inputs & Text Editors and related app architectures.
ButtonsiOS 16.0+
Bouncy Button Icon
Interactive button featuring fluid spring animations and smooth scale feedback upon tap.
View Component & Code
ButtonsiOS 16.0+
Button with Repeat Behavior
Stepper-like button with continuous press-and-hold repeating action for counters and volume adjustment.
View Component & Code
ButtonsiOS 16.0+
Button for Copying
Smart copy button that temporarily switches icon and text to "Copied!" with tactile haptic feedback.
View Component & Code