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
idStringOptional component ID
mediaComponentImage or component placed at the top of the card
headerPrefixComponentComponent rendered before the title area
headerComponentReplaces the default title/subtitle header
titleComponentCard title
subtitleComponentCard subtitle
headerSuffixComponentComponent rendered after the title area
contentComponentMain body content
footerComponentFooter content
variantsList<CardVariant>[]One or more display variants
styleStringInline CSS
cssClassesStringCSS 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()