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?
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 Updated Answer:
Text("Bold Text").bold() Text("**Bold Text**") Text("*Italic Text*") Text("***Bold Italic Text***") 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() } } .font(.system(size: 30, weight: .heavy, design: .default)) is that we MUST define the font size. If we just want to stick guidelines with predefined .title .body kind font sizes this method is not ideal.SwiftUI supports markdown.
Add double asterisks (**) arroud the text/characters to make it bold.
Text("**This text is bold**") To emphasize text, use underscore
Text("_This text is italic_") .fontWeight(.black) insteadThe updated approach for iOS 13.0+, macOS 10.15+, tvOS 13.0+, watchOS 6.0+ is:
.fontWeight(.bold) TextField, so it's not really an answer to the question.fontWeight is suitable for Text views but not for TextFields since they don't expose their label views. Thus .font(Font.body.bold()) is still the simplest solution :(fontWeight is for iOS 13+. iOS 16+ is the overriden one that returns Text.Expanding on shawnynicole's answer, you can create an extension:
extension View { func bold() -> some View { font(Font.body.bold()) } } and apply it to any View (including the TextField):
TextField("Text", text: $text) .bold()