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

Icon Field

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

A field with a leading icon.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

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

import SwiftUI

// Field with leading icon
struct IconField: View {
    var body: some View {
        HStack(spacing: 10) {
            Image(systemName: "envelope").font(.system(size: 16)).foregroundStyle(.secondary)
            Text("Email address").font(.system(size: 16)).foregroundStyle(.secondary)
            Spacer()
        }.padding(.horizontal, 14).padding(.vertical, 14).overlay(RoundedRectangle(cornerRadius: 12, style: .continuous).stroke(Color.primary.opacity(0.15), lineWidth: 1)).frame(width: 300)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17