Skip to content

Repository files navigation

FloatingLabelTextField

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.


✨ Features

  • ✅ 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

🖼 Example Preview

Here’s how it looks in the demo:

📦 Installation

Swift Package Manager

You can add FloatingLabelTextField to your project in two ways:

  1. Xcode

    • Go to File > Add Packages...

    • Enter the URL of this repo:

      https://github.com/devstacklimited/FloatingLabelTextField.git
      
    • Select the version rule and finish.

  2. Package.swift

    dependencies:[.package(url:"https://github.com/devstacklimited/FloatingLabelTextField.git", from:"1.0.0")]

🚀 Usage

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()}}

⚙️ Parameters

ParameterTypeDefaultDescription
labelStringFloating label text
textBinding<String>Bound text value
placeholderString?nilPlaceholder text
isSecureBoolfalseEnables secure entry + toggle
labelColorColor.blackFloating label text color
keyboardTypeUIKeyboardType.defaultKeyboard type
autocapitalizationTextInputAutocapitalization?.sentencesAutocapitalization mode
heightCGFloat48Field height
cornerRadiusCGFloat8Border corner radius
borderColorColor.primaryBorder color
borderWidthCGFloat1Border width
labelFontFont.system(size: 12)Label font
textFontFont.system(size: 16)Input text font

💡 Contributing

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.

📝 License

FloatingLabelTextField is available under the MIT License.

About

A lightweight SwiftUI library that provides a customizable floating label text field with outlined border, secure password toggle (eye icon), and Material Design–inspired style. Supports iOS 14+ and Swift Package Manager.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages