A lightweight and customizable SwiftUI text field with a floating label.
This package provides a Material Design–inspired floating label input field for iOS, making form UIs clean, modern, and user-friendly.
- ✅ Floating label with customizable font and color
- ✅ Secure text entry with show/hide password toggle
- ✅ Fully customizable:
- Height
- Corner radius
- Border color and width
- Label font and color
- Text font
- ✅ Supports iOS 14+
- ✅ Swift Package Manager support
Here’s how it looks in the demo:
You can add FloatingLabelTextField to your project in two ways:
Xcode
Go to
File > Add Packages...Enter the URL of this repo:
https://github.com/devstacklimited/FloatingLabelTextField.gitSelect the version rule and finish.
Package.swift
dependencies:[.package(url:"https://github.com/devstacklimited/FloatingLabelTextField.git", from:"1.0.0")]
import SwiftUI
import FloatingLabelTextField
structContentView:View{@Stateprivatevarusername:String=""@Stateprivatevarpassword:String=""varbody:someView{VStack(spacing:20){
// Normal TextField
FloatingLabelTextField(
label:"Username",
text: $username,
placeholder:"Enter your username",
labelColor:.gray,
borderColor:.blue,
labelFont:.system(size:14, weight:.medium),
textFont:.system(size:16))
// Secure TextField with toggle
FloatingLabelTextField(
label:"Password",
text: $password,
placeholder:"Enter your password",
isSecure:true,
labelColor:.gray,
borderColor:.red,
labelFont:.system(size:14, weight:.medium),
textFont:.system(size:16))}.padding()}}| Parameter | Type | Default | Description |
|---|---|---|---|
label | String | — | Floating label text |
text | Binding<String> | — | Bound text value |
placeholder | String? | nil | Placeholder text |
isSecure | Bool | false | Enables secure entry + toggle |
labelColor | Color | .black | Floating label text color |
keyboardType | UIKeyboardType | .default | Keyboard type |
autocapitalization | TextInputAutocapitalization? | .sentences | Autocapitalization mode |
height | CGFloat | 48 | Field height |
cornerRadius | CGFloat | 8 | Border corner radius |
borderColor | Color | .primary | Border color |
borderWidth | CGFloat | 1 | Border width |
labelFont | Font | .system(size: 12) | Label font |
textFont | Font | .system(size: 16) | Input text font |
Contributions, issues, and feature requests are welcome! If you use this library and like it, don’t forget to star the repo ⭐️. It helps the project grow and reach more developers.
FloatingLabelTextField is available under the MIT License.



