Skip to content
Floating Label preview
Rendered from the SwiftUI source on this page.

Floating Label

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

A field with a floating, focused label.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

FloatingLabelInput.swift
// Floating Label · syxUI · https://syxui.dev/components/inp-floating
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let inpBlue = Color(red: 0.0, green: 0.47, blue: 1.0)

// Floating label field (focused)
struct FloatingLabelInput: View {
    var body: some View {
        VStack(alignment: .leading, spacing: 2) {
            Text("Email").font(.system(size: 12, weight: .medium)).foregroundStyle(inpBlue).padding(.horizontal, 14).padding(.top, 9)
            Text("jane@example.com").font(.system(size: 16)).padding(.horizontal, 14).padding(.bottom, 10)
        }.frame(maxWidth: .infinity, alignment: .leading).overlay(RoundedRectangle(cornerRadius: 12, style: .continuous).stroke(inpBlue, lineWidth: 1.5)).frame(width: 300)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17