Cards provide a standard way of representing group information.
They have various options depending on what data you want to provide and how you want it to look.
Here's an example card, with image, content, and a button going back to the homepage:
Card(imageName: "/images/photos/dishwasher.jpg") {
Text("Before putting your dishes into the dishwasher, make sure and give them a quick pre-clean.")
Link("Back to the homepage", target: "/")
.linkStyle(.button)
}
.frame(maxWidth: 300)
Before putting your dishes into the dishwasher, make sure and give them a quick pre-clean.
Back to the homepageYou can attach headers and/or footers to your cards, and they automatically get styled appropriately. This is in addition to any image you provide, or any titles used in the card body.
Card {
Text("This is important!")
.font(.title3)
Text("This is card body text. This is card body text. This is card body text. This is card body text. This is card body text.")
} header: {
"Header Example"
} footer: {
"Your footer goes here footer"
}This is card body text. This is card body text. This is card body text. This is card body text. This is card body text.
Cards have three styles: .default, .solid, and .bordered, and can also be assigned roles. The .default style does nothing special, but both .solid and .bordered apply coloring based on role.
for style in Card.CardStyle.allCases {
if style != .default {
Text(markdown: "`\(style)` style")
.font(.title3)
for role in Role.allCases {
Card {
"This is a \(style) card with the \(role) role."
} header: {
"Header"
}
.role(role)
.cardStyle(style)
.margin(.bottom)
}
Spacer(size: .extraLarge)
}
}solid stylebordered styleCreated with Ignite