How To Use Markdown in SwiftUI

Discover different ways to use Markdown with the Text element in SwiftUI to easily add markdown text to your app.

Francesco Leoni

1 min read

Availability

iOS 13.0

macOS 10.15

tvOS 13.0

watchOS 6.0

The markdown feature of the Text element is a great feature!

You can just type your markdown string and SwiftUI will render the text formatted.

Let's see different ways to use it.

Usage

You can use a string literal

Text("This will be bold")

Or you can pass the text from a variable

let markdownText = "This will be bold"

// […]

Text(.init(markdownText))

Conclusion

Now you can markdown text in your app. Happy coding!

I hope I helped you with you journey with SwiftUI and iOS development.

See you in the next guide!

If you have any question about this article, feel free to email me or tweet me @franceleonidev and share your opinion.

Thank you for reading and see you in the next article!

Share this article

Related articles


Combine CoreData and SwiftUI

See how to use CoreData database with SwiftUI. Syncing changes from CoreData to every View of your app.

5 min read

SwiftUICoreData

SwiftData the Successor of CoreData Explained with SwiftUI

Discover the SwiftData framework built on top of CoreData. Save and fetch data locally. Available for Xcode 15, Swift and SwiftUI.

5 min read

SwiftUICoreData

Make your Chart Scrollable with SwiftUI Charts (iOS 17)

Discover the new SwiftUI Charts APIs that enables you to create scrollable chart easily. Available for Xcode 15 and iOS 17.

2 min read

ChartsSwiftUI