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

Clearable Field

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

A field with a clear button.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

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

import SwiftUI

// Field with clear button
struct ClearableField: View {
    var body: some View {
        HStack(spacing: 10) {
            Text("Jane Appleseed").font(.system(size: 16))
            Spacer()
            Image(systemName: "xmark.circle.fill").font(.system(size: 16)).foregroundStyle(.secondary)
        }.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