SP GlassKit1.1.0

GlassTextArea

Multiline editor with an accessible placeholder, optional limit and counter.

  • Content
  • iOS 26 · iPadOS 26 · macOS 26
  • Version 1.1.0
  • glass-text-area

Content on an opaque, readable surface. Glass is kept for controls.

GlassTextArea running in SP Glass Studio.Capture
Capture of the component running in SP Glass Studio on the iOS 26.5 simulator. Liquid Glass is rendered by the system; this is an image, not a live preview.

Installation

spglass add glass-text-area

Copies the sources and their dependencies into your project. Set up the CLI.

Swift
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")

import SPGlassKit
Identifierglass-text-area
ModuleSPGlassForms
Kindcontent-component — a system TextEditor on an opaque themed surface
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/Gallery/Forms/GlassTextAreaExample.swift

Minimal usage

Swift
@State private var notes = ""

GlassTextArea("Notes", text: $notes)

Variants

VariantUse
placeholder:Text shown while the editor is empty.
limit:Largest number of characters; extra input is dropped and the counter appears.
showsCounter: trueA counter without a limit ("42").
helper: / errorMessage:Text under the editor; the error replaces the helper.
minHeight:Smallest height at the default text size; it scales with Dynamic Type.

Parameters

ParameterTypeDefaultMeaning
labelLocalizedStringKey—Label above the editor; also its accessibility label.
textBinding<String>—The value.
placeholderString?nilPlaceholder, already localised.
helperLocalizedStringKey?nilHelper text.
limitInt?nilCharacter limit.
showsCounterBool?nilCounter visibility; nil shows it when there is a limit.
minHeightCGFloat96Minimum height before Dynamic Type scaling.
errorMessageString?nilExternal error.

States

Empty (placeholder), focused (outline), at the limit (counter in the warning colour, the numbers themselves say so), error, disabled. The counter reads "12/280"; VoiceOver hears "12 of 280 characters".

Advanced example

Swift
GlassTextArea(
    "Review", text: $review,
    placeholder: String(localized: "What did you think of your stay?"),
    helper: "Visible to everyone.",
    limit: 500,
    minHeight: 140,
    errorMessage: review.count < 20 && didSubmit ? String(localized: "Write at least 20 characters.") : nil
)

Counting and clamping are public and pure: GlassTextLimit.clamp("a👨‍👩‍👧‍👦b", to: 2) gives "a👨‍👩‍👧‍👦".

Accessibility

  • The label is the accessibility label of the editor. While it is empty, the placeholder is read as its value; the painted placeholder itself is hidden from assistive technologies.
  • The limit counts user-perceived characters: an emoji, a flag or an accented letter counts as one and is never cut in two.
  • The counter has a spoken form with words, and digits follow the locale.
  • The minimum height grows with the text size; the editor scrolls inside it.

Limits

  • Plain text only (String); no rich text or attachments.
  • The limit is applied after the system inserted the text, so an over-long paste appears and is cut in the same update.
  • The placeholder is aligned with the first line by per-platform insets, which may drift by a point if the system changes the editor's padding.
  • Scrolling, selection and the keyboard are the system's; they were not exercised on a running device here.

Example

Complete example (compiled with the package)
import SwiftUI
import SPGlassKit

public struct GlassTextAreaExample: GlassExample {
    public static let componentID = "glass-text-area"
    @State private var notes = ""
    @State private var bio = "Hiking 🥾, bread 🍞 and old maps 🗺️."
    @State private var feedback = "Too short"

    public init() {}

    public var body: some View {
        ScrollView {
            VStack(alignment: .leading, spacing: 20) {
                GlassTextArea("Notes", text: $notes, placeholder: "Anything the team should know before the visit", helper: "Visible to your team only.")

                GlassTextArea("Short bio", text: $bio, limit: 40)

                GlassTextArea(
                    "Feedback",
                    text: $feedback,
                    showsCounter: true,
                    minHeight: 72,
                    errorMessage: feedback.count < 20 ? "Please write at least 20 characters." : nil
                )

                GlassTextArea("Archived comment", text: .constant("This comment can no longer be edited."))
                    .disabled(true)
            }
            .padding()
        }
    }
}

#Preview("GlassTextArea") { GlassTextAreaExample().glassTheme(.solar) }

Registry entry

Identifierglass-text-area
Version1.1.0
Depends onglass-forms-support, glass-foundation
FrameworksSwiftUI
Public symbolsGlassTextLimit, GlassTextArea
LicenceMIT
Manifestmanifest.json

Files