How to bold text in TextField swiftUI?
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
.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()
}
}
TextField("Name", text: $name)
.font(Font.body.bold())