Skip to content

Commit 4426895

Browse files
Updated ReadMe file
1 parent ae9d45f commit 4426895

File tree

1 file changed

+114
-3
lines changed

1 file changed

+114
-3
lines changed

README.md

Lines changed: 114 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,117 @@
11
# FloatingLabelTextField
22

3-
A small SwiftUI component that renders an outlined (bordered) text field with an in-border label,
4-
designed to be easy for beginners to use.
3+
A lightweight and customizable **SwiftUI text field with a floating label**.
4+
This package provides a Material Design–inspired floating label input field for iOS, making form UIs clean, modern, and user-friendly.
55

6-
Import the package in Xcode or via Swift Package Manager and use `FloatingLabelTextField`.
6+
---
7+
8+
## ✨ Features
9+
10+
- ✅ Floating label with customizable font and color
11+
- ✅ Secure text entry with **show/hide password** toggle
12+
- ✅ Fully customizable:
13+
- Height
14+
- Corner radius
15+
- Border color and width
16+
- Label font and color
17+
- Text font
18+
- ✅ Supports **iOS 14+**
19+
- ✅ Swift Package Manager support
20+
21+
---
22+
23+
## 📦 Installation
24+
25+
### Swift Package Manager
26+
27+
You can add **FloatingLabelTextField** to your project in **two ways**:
28+
29+
1. **Xcode**
30+
- Go to `File > Add Packages...`
31+
- Enter the URL of this repo:
32+
33+
```
34+
https://github.com/devstacklimited/FloatingLabelTextField.git
35+
```
36+
37+
- Select the version rule and finish.
38+
39+
2. **Package.swift**
40+
41+
```swift
42+
dependencies: [
43+
.package(url: "https://github.com/devstacklimited/FloatingLabelTextField.git", from: "1.0.0")
44+
]
45+
```
46+
47+
## 🚀 Usage
48+
49+
```swift
50+
import SwiftUI
51+
import FloatingLabelTextField
52+
53+
struct ContentView: View {
54+
@State private var username: String = ""
55+
@State private var password: String = ""
56+
57+
var body: some View {
58+
VStack(spacing: 20) {
59+
// Normal TextField
60+
FloatingLabelTextField(
61+
label: "Username",
62+
text: $username,
63+
placeholder: "Enter your username",
64+
labelColor: .gray,
65+
borderColor: .blue,
66+
labelFont: .system(size: 14, weight: .medium),
67+
textFont: .system(size: 16)
68+
)
69+
70+
// Secure TextField with toggle
71+
FloatingLabelTextField(
72+
label: "Password",
73+
text: $password,
74+
placeholder: "Enter your password",
75+
isSecure: true,
76+
labelColor: .gray,
77+
borderColor: .red,
78+
labelFont: .system(size: 14, weight: .medium),
79+
textFont: .system(size: 16)
80+
)
81+
}
82+
.padding()
83+
}
84+
}
85+
```
86+
87+
## ⚙️ Parameters
88+
89+
| Parameter | Type | Default | Description |
90+
| -------------------- | ------------------------------ | ------------------- | ----------------------------- |
91+
| `label` | `String` || Floating label text |
92+
| `text` | `Binding<String>` || Bound text value |
93+
| `placeholder` | `String?` | `nil` | Placeholder text |
94+
| `isSecure` | `Bool` | `false` | Enables secure entry + toggle |
95+
| `labelColor` | `Color` | `.black` | Floating label text color |
96+
| `keyboardType` | `UIKeyboardType` | `.default` | Keyboard type |
97+
| `autocapitalization` | `TextInputAutocapitalization?` | `.sentences` | Autocapitalization mode |
98+
| `height` | `CGFloat` | `48` | Field height |
99+
| `cornerRadius` | `CGFloat` | `8` | Border corner radius |
100+
| `borderColor` | `Color` | `.primary` | Border color |
101+
| `borderWidth` | `CGFloat` | `1` | Border width |
102+
| `labelFont` | `Font` | `.system(size: 12)` | Label font |
103+
| `textFont` | `Font` | `.system(size: 16)` | Input text font |
104+
105+
106+
## 🛠️ Example Preview
107+
Here’s how it looks with default values:
108+
109+
<img src="https://via.placeholder.com/500x150.png?text=FloatingLabelTextField+Preview" alt="Preview" width="500"/>
110+
111+
112+
## 💡 Contributing
113+
Contributions, issues, and feature requests are welcome!
114+
If you use this library and like it, **don’t forget to star the repo** ⭐️. It helps the project grow and reach more developers.
115+
116+
## 📝 License
117+
FloatingLabelTextField is available under the MIT License.

0 commit comments

Comments
 (0)