TechnologiesSwiftUI

WritingToolsBehavior struct

iOSmacOStvOSwatchOSvisionOS✓ renders

The Writing Tools editing experience for text and text input.

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.

  1. 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 TextField and the read-only Text(draft) each receive their own behavior.

  2. 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 the TextField bound to $draft makes that editable field a first-class Writing Tools surface, where rewriting and proofreading are most useful.

  3. Turn it off with the disabled behavior

    WritingToolsBehavior.disabled suppresses Writing Tools entirely for the view. Putting .writingToolsBehavior(.disabled) on the lower Text(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.

  4. 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.

Try it — Change the lower view's .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.

WritingToolsBehavior.swift
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()
    }
}
Live preview
Compose Select this text to see Writing Tools. Select this text to see Writing Tools.
Compose Select this text to see Writing Tools. Select this text to see Writing Tools.
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →