A ViewModifier is a protocol that can be called on a particular view. Modifier methods adhere to the protocol and return a new, altered View that will replace the originally created View.


struct MyView: View {
    var body: some View {
        View(s) here
            Modifier methods like .bold() can be called underneath a View.
            Multiple modifiers can be chained using dot notation.


The following example displays some text:

import SwiftUI
struct ContentView: View {
var name: String = "Sam"
var body: some View {
Text("Hello \(name)")

In the example above, the .font() and .bold() modifiers are called on a Text view. In addition, a built-in text style, .title property, is passed into the .font() modifier.

This will display:

SwiftUI Modifier


Applies a bold style to text characters in a View.
Indicates that the font inside a view should have an italic style applied to it.
Applies an underline style to text characters in a view.


Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn SwiftUI on Codecademy