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

Underline Text Field

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

A underline text field input — self-contained SwiftUI, styled from system tokens.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

UnderlineField.swift
// Underline Text Field · syxUI · https://syxui.dev/components/input-underline
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

extension View {
    func formaCard(_ pad: CGFloat = 18) -> some View {
        self.padding(pad)
            .background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: 20, style: .continuous))
            .overlay(RoundedRectangle(cornerRadius: 20, style: .continuous).stroke(Color.primary.opacity(0.06), lineWidth: 1))
            .shadow(color: .black.opacity(0.05), radius: 14, x: 0, y: 6)
    }
}

// 13. Underline field
struct UnderlineField: View {
    var body: some View {
        VStack(alignment: .leading, spacing: 22) {
            VStack(alignment: .leading, spacing: 6) {
                Text("Email address").font(.system(size: 15)).foregroundStyle(.primary)
                Rectangle().fill(Color.primary).frame(height: 1.5)
            }
            VStack(alignment: .leading, spacing: 6) {
                Text("Password").font(.system(size: 15)).foregroundStyle(.tertiary)
                Rectangle().fill(Color.primary.opacity(0.2)).frame(height: 1)
            }
        }
        .formaCard()
    }
}
iOS 17 · 1 dependencies

Dependencies

SwiftUI
  • formaCard

Requires iOS 17