Skip to content
Error Field preview
Rendered from the SwiftUI source on this page.

Error Field

From syxUI — written for both platforms, not translated between them.

A field in an error state with a message.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

ErrorField.swift
// Error Field · syxUI · https://syxui.dev/components/inp-error
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

// Error state field
struct ErrorField: View {
    let red = Color(red: 0.90, green: 0.24, blue: 0.28)
    var body: some View {
        VStack(alignment: .leading, spacing: 6) {
            HStack { Text("invalid-email").font(.system(size: 16)); Spacer(); Image(systemName: "exclamationmark.circle.fill").foregroundStyle(red) }.padding(.horizontal, 14).padding(.vertical, 14).overlay(RoundedRectangle(cornerRadius: 12, style: .continuous).stroke(red, lineWidth: 1.5))
            Text("Please enter a valid email").font(.system(size: 12)).foregroundStyle(red).padding(.leading, 4)
        }.frame(width: 300)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17