Fix: TextField expands to fill width, label is accessibility-only

- TextField now expands to fill available width (SwiftUI behavior)
- Label parameter is for accessibility only, not rendered visually
- Use prompt: parameter for placeholder text
- Update example app to use prompt: correctly
- SecureField also expands to fill available width
This commit is contained in:
phranck
2026-02-13 16:18:14 +01:00
parent f8e255da06
commit d700731777
3 changed files with 21 additions and 19 deletions
@@ -74,11 +74,11 @@ struct TextFieldPage: View {
VStack(alignment: .leading, spacing: 1) {
HStack(spacing: 1) {
Text("Input:").foregroundStyle(.palette.foregroundSecondary)
TextField("Type here...", text: $demoText)
TextField("Input", text: $demoText, prompt: Text("Type here..."))
}
HStack(spacing: 1) {
Text("Search:").foregroundStyle(.palette.foregroundSecondary)
TextField("Search", text: $searchQuery)
TextField("Search", text: $searchQuery, prompt: Text("Enter search term..."))
.onSubmit { submittedValue = searchQuery }
}
if !submittedValue.isEmpty {
@@ -95,7 +95,8 @@ struct TextFieldPage: View {
VStack(alignment: .leading, spacing: 1) {
HStack(spacing: 1) {
Text("Disabled:").foregroundStyle(.palette.foregroundSecondary)
TextField("Disabled", text: $disabledText).disabled()
TextField("Disabled", text: $disabledText, prompt: Text("Cannot edit"))
.disabled()
}
}
}