How it works
WritingToolsBehavior describes how Apple's system Writing Tools — proofreading, rewriting, summarizing, and the other text transformations — surface for a given view. It is the value you pass to the writingToolsBehavior(_:) modifier to declare, per view, whether those affordances appear automatically, only on demand, or not at all. Reach for it when a view contains text the user might edit or select and you want to tune, or suppress, the system's text-assistance experience for that particular content rather than accepting the platform default.
Apply it with the writingToolsBehavior(_:) modifier
The behavior takes effect only when you attach it to a view that hosts text. The writingToolsBehavior(_:) modifier carries a single WritingToolsBehavior value and scopes it to the view it modifies and that view's descendants, so different parts of a hierarchy can opt into different levels of assistance — here the editable
TextFieldand the read-onlyText(draft)each receive their own behavior.Opt fully in with the complete behavior
WritingToolsBehavior.complete enables the full Writing Tools experience, including the inline affordances the system can offer as the user works. Applying
.writingToolsBehavior(.complete)to theTextFieldbound to$draftmakes that editable field a first-class Writing Tools surface, where rewriting and proofreading are most useful.Turn it off with the disabled behavior
WritingToolsBehavior.disabled suppresses Writing Tools entirely for the view. Putting
.writingToolsBehavior(.disabled)on the lowerText(draft)keeps the system from offering text transformations on content that is only being displayed, not authored, so the feature appears exactly where editing happens.Fall back to limited and the platform default
Beyond the two extremes, WritingToolsBehavior offers
.limited, which keeps the basic selection-driven entry point without the richer automatic affordances of.complete. When you apply no modifier at all, the view uses the platform's default behavior, so reach for an explicit case only when you want to deviate from it.
.writingToolsBehavior(.disabled) to .writingToolsBehavior(.complete) and select the displayed text — the same Writing Tools affordances now appear on content you previously kept read-only.Example & preview
Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.
struct WritingToolsBehaviorDemo: View {
@State private var draft = "Select this text to see Writing Tools."
var body: some View {
VStack(alignment: .leading, spacing: 16) {
Text("Compose")
.font(.headline)
TextField("Notes", text: $draft, axis: .vertical)
.textFieldStyle(.roundedBorder)
.writingToolsBehavior(.complete)
Text(draft)
.writingToolsBehavior(.disabled)
.foregroundStyle(.secondary)
}
.padding()
}
}