GlassTextArea
| Identifier | glass-text-area |
| Module | SPGlassForms |
| Kind | content-component — a system TextEditor on an opaque themed surface |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Forms/GlassTextAreaExample.swift |
Minimal usage
swift
@State private var notes = ""
GlassTextArea("Notes", text: $notes)Variants
| Variant | Use |
|---|---|
placeholder: |
Text shown while the editor is empty. |
limit: |
Largest number of characters; extra input is dropped and the counter appears. |
showsCounter: true |
A 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
| Parameter | Type | Default | Meaning |
|---|---|---|---|
label |
LocalizedStringKey |
— | Label above the editor; also its accessibility label. |
text |
Binding<String> |
— | The value. |
placeholder |
String? |
nil |
Placeholder, already localised. |
helper |
LocalizedStringKey? |
nil |
Helper text. |
limit |
Int? |
nil |
Character limit. |
showsCounter |
Bool? |
nil |
Counter visibility; nil shows it when there is a limit. |
minHeight |
CGFloat |
96 |
Minimum height before Dynamic Type scaling. |
errorMessage |
String? |
nil |
External 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.