📦 SwiftyLaunch Modules
🔗 SharedKit
🎨 UI Elements, Styles
TextField Style

Common Textfield Style (CommonTextField())

SharedKit (SwiftyLaunch Module) - Common Textfield Style

For your Textfields to have a common appearance, we include a textifeld style called CommonTextField(). Simply attach it to your textfield to give it a consistent look.

Definition

CommonTextField.swift
public struct CommonTextField: TextFieldStyle {
	public init(disabled: Bool = false) {
		self.disabled = disabled
	}
}
  • disabled (Optional): A boolean value to determine if the textfield is disabled or not. Default is false.

Usage Example

VStack (spacing: 20) {
    TextField("Test TextField", text: .constant("Hello"))
        .textFieldStyle(CommonTextField())
    TextField("Test TextField", text: .constant("Hello"))
        .textFieldStyle(CommonTextField(disabled: true))
}

Common Textield Style Example

Styling

You can additionally change the default height, radius and font of the the textfield by editing the constants values on top of the CommonTextField.swift file.

CommonTextField.swift
let commonTextFieldRadius = 10.0
let commonTextFieldHeight = 50.0
let commonTextFieldFontStyle: Font = .system(.body, weight: .regular)