Skip to main content
.textSelection(mode: "enabled" | "disabled"): Component
mode
"enabled" | "disabled"
required
Whether text selection is enabled or disabled.

Support

Usage

Enable text selection

Allow users to select and copy text content.
Text("You can select and copy this text.")
    .textSelection("enabled")

Disable text selection

Prevent text from being selected, useful for labels or decorative text.
Text("This text cannot be selected.")
    .textSelection("disabled")

Selectable paragraph

VStack({ alignment: "leading", spacing: 8 }, [
    Text("Article Title")
        .font("title")
        .textSelection("disabled"),
    Text("This is the body of the article. Users can select and copy this content for sharing.")
        .textSelection("enabled"),
])