How to Open URLs and Customize Links in SwiftUI

In SwiftUI, you can use the Link view to create clickable links that take the user to a website or web page. By default, when the user taps on a link, it will open in the system's default web browser. However, you can also customize the link behavior and appearance by using modifiers.

Learn how to open a URL in the Safari browser and how to customize your Link


  • View Using the Link object, we're setting the text and the destination which is of type URL. 
  • Note that a URL cannot be an option, which is why we're adding the exclamation point at the end.

Link("Bolt UIX",
      destination: URL(string: "")!)


Customize the Link 

Similar to a Text, you can customize the Link by using modifiers like font or foregroundColor.

Link("Bolt UIX",
      destination: URL(string: "")!)


Icon Link 

You can also wrap the Link around any element such as the Image.

Link(destination: URL(string: "")!) {
    Image(systemName: "link")
        .frame(width: 32, height: 32)