Links
Links direct users to other parts of your site, or to external locations.
In the simplest case we can create a link with a string target:
Text {
Link("Go Home", target: "/")
}
Alternatively, you can use page types directly to get their path:
Text {
Link("Learn about carousels", target: CarouselExamples())
}
Using a .target(.blank) modifier opens new tabs:
Text {
Link("Another tab of links", target: LinkExamples())
.target(.blank)
}
Tip: Page targets use initialized pages, so you can pass in custom values that adjust the path.
Use LinkGroup when you need to make multiple HTML elements clickable as a single link:
LinkGroup(target: "/") {
Section {
Text("Building Modern Websites")
.font(.title3)
Text("Learn how to create beautiful, responsive interfaces using Ignite's declarative syntax.")
.font(.lead)
}
.border(.lightGray)
.padding()
.cornerRadius(5)
.frame(maxWidth: 500)
}
Building Modern Websites
Learn how to create beautiful, responsive interfaces using Ignite's declarative syntax.
Link styling
Links can have roles to control how they appear:
ForEach(Role.standardRoles) { role in
Text {
Link("Link with \(role.rawValue) role.", target: "#")
.role(role)
}
}
Links as buttons
Use linkStyle(.button) to style links as buttons:
ForEach(Role.standardRoles) { role in
Text {
Link("Button-style link with \(role.rawValue) role.", target: "#")
.linkStyle(.button)
.role(role)
}
}
Button-style link with primary role.
Button-style link with secondary role.
Button-style link with success role.
Button-style link with danger role.
Button-style link with warning role.
Button-style link with info role.