Skip to content

Card

A content card with optional media, header, title, subtitle, body, and footer areas. Supports multiple visual variants.

Card.builder()
.title(new Text("Title"))
.subtitle(new Text("Subtitle"))
.content(new Text("Body content goes here."))
.build()
PropertyTypeDefaultDescription
idString—Optional component ID
mediaComponent—Image or component placed at the top of the card
headerPrefixComponent—Component rendered before the title area
headerComponent—Replaces the default title/subtitle header
titleComponent—Card title
subtitleComponent—Card subtitle
headerSuffixComponent—Component rendered after the title area
contentComponent—Main body content
footerComponent—Footer content
variantsList<CardVariant>[]One or more display variants
styleString—Inline CSS
cssClassesString—CSS class names
ValueDescription
elevatedAdds a drop shadow
outlinedAdds a visible border
stretchMediaMedia image fills the card width edge-to-edge
coverMediaMedia image covers the whole card background
horizontalPuts media and content side by side

Variants can be combined:

.variants(List.of(CardVariant.outlined, CardVariant.stretchMedia))
Card.builder()
.title(new Text("Widget A"))
.subtitle(new Text("In stock"))
.content(new Text("€ 9.99"))
.media(new Image("https://example.com/product.jpg"))
.variants(List.of(CardVariant.elevated))
.build()
Card.builder()
.title(new Text("Article title"))
.content(new Text("Article excerpt…"))
.media(new Image("https://example.com/thumb.jpg"))
.variants(List.of(CardVariant.horizontal))
.build()
Card.builder()
.title(new Text("Hero card"))
.content(new Text("Content over the image"))
.media(new Image("https://example.com/hero.jpg"))
.variants(List.of(CardVariant.coverMedia))
.build()

Use HorizontalLayout with wrap to create a card gallery:

HorizontalLayout.builder()
.wrap(true)
.spacing(true)
.content(products.stream()
.map(p -> Card.builder()
.title(new Text(p.getName()))
.content(new Text("€ " + p.getPrice()))
.build())
.toList())
.build()