There is no built-in font-weight modifier for textfield in SwiftUI, as of Xcode 11.2.1.
How can we introduce font-weight without extending UITextField as UIViewRepresentable?
Hold the command key and click the text to bring up a pop-over menu. Choose Show SwiftUI Inspector and then you can edit the text/font properties.
SwiftUI lets you customize Text by applying a . font() modifier. The default iOS font is called San Francisco and if you don't explicitly change it, then all of your text will have the default iOS look. Some other options of standard fonts include: title, headline, subheadline, body, callout, caption or footnote.
A general approach for using standard font size options and weights that work with SwiftUI TextField. For example:
TextField("Name", text: $name) .font(Font.headline.weight(.light))
Available standard size options (smallest to largest):
.caption .footnote .subheadline .callout .body .headline .title3 .title2 .title .largeTitle
Available standard font weights (lightest to heaviest):
.ultralight .thin .light .regular .medium .semibold .bold .heavy .black
import SwiftUI struct ContentView: View { @State var TextValue: String = "Hello" var body: some View { VStack { TextField("placeholder", text: $TextValue) .padding(.horizontal, 50) .font(.system(size: 30, weight: .heavy, design: .default)) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With