- Xcode 11+
- SwiftUI
- iOS 14+
- macOS 10.15+
File ➜ Swift Packages ➜ Add Package Dependancy..
.package(url: "https://github.com/Changemin/FloatingTextField", from: "1.1.0")FloatingTextField(_ content: Binding<String>, placeholder: String)
FloatingSecureField(_ content: Binding<String>, placeholder: String)
// Secure Field for passwordcontent: user inputplaceholder: placeholder text before add text
FloatingTextField(_ content: Binding<String>, placeholder: String)
.accentColor(_ color: Color)
.contentType(_ contentType: ContentType)
.icon(systemName icon : String)
.showClearButton(_ show: Bool)
.styled(_ style: FloatingTextFieldStyle)
// All of the parameter is optional.accentColor(): Width of button.contentType():.none.email.number.phone.namesupport different keyboard type.icon(): icon name ofSF Symbols.showClearButton(): to show clear button or not.styled()(In Progess) :FloatingTextFieldStyle.normal,FloatingTextFieldStyle.sqaure
import SwiftUI
import FloatingTextField
struct ContentView: View {
@State var input: String = ""
var body: some View {
FloatingTextField($input, placeholder: "Please type")
.padding()
}
}import SwiftUI
import FloatingTextField
struct ContentView: View {
@State var input: String = ""
var body: some View {
FloatingTextField($input, placeholder: "Please type")
.icon(systemName: "flame.fill")
.padding()
}
}import SwiftUI
import FloatingTextField
struct ContentView: View {
@State var input: String = ""
var body: some View {
FloatingTextField($input, placeholder: "Nick Name")
.icon(systemName: "flame.fill")
.contentType(.name)
.accentColor(Color.orange)
.autocapitalization(.none)
.disableAutocorrection(true)
.padding()
}
}You can also use TextField modifiers like .autocapitalization() .autocapitalization()
- Square Style
- Add Restrict Options
- Validation Check
FloatingTextField is available under the MIT license. See the LICENSE file for more info.
- Byun Kyung Min ➜ 🇰🇷@Changemin







