CardComponent

open class CardComponent : Component<Unit>

This class combines the configuration and rendering of a CardComponent.

A card consists of arbitrary content that is optionally decorated with a header and a footer. Cards can be configured in different sizes and offer the following configurable properties:

  • size: The size of the card, ranging from small to large. Both the font-size and margins are set accordingly.

  • content: The main content of the card

  • header: The header area of the card

  • footer: The footer area of the card

An optional styling parameter can be passed to the above properties in case you specify custom content via RenderContext.

The content-related properties (header, footer and content) don't only take layouts but also Strings and Flows of Strings for your convenience. Cards are created via the card factory function.

Cards can have different types which are the same as in PaperComponent. This is due to the fact, that the CardComponent uses a PaperComponent internally. The type can be specified via the type property.

Usage example:

card {
size { small }
type { normal }
paperType { normal }
header("Header")
content("Lorem ipsum, dolor sit amet...")
footer("Footer")
}

card {
size { normal }
header("Simple Header")
content({
// Optional additional styling
background { color { gray300 } }
}) {
span {
+"Custom Content"
}
}
}

Constructors

CardComponent
Link copied to clipboard
js
fun CardComponent()

Types

CardSection
Link copied to clipboard
js
data class CardSection(styling: Style<BoxParams>, value: RenderContext.() -> Unit)
Companion
Link copied to clipboard
js
object Companion
Sizes
Link copied to clipboard
js
enum Sizes : Enum<CardComponent.Sizes>
SizesContext
Link copied to clipboard
js
object SizesContext

Functions

content
Link copied to clipboard
js
fun content(value: String)
fun content(value: Flow<String>)
fun content(styling: Style<BoxParams> = {}, value: RenderContext.() -> Unit)
footer
Link copied to clipboard
js
fun footer(value: String)
fun footer(value: Flow<String>)
fun footer(styling: Style<BoxParams> = {}, value: RenderContext.() -> Unit)
header
Link copied to clipboard
js
fun header(value: String)
fun header(value: Flow<String>)
fun header(styling: Style<BoxParams> = {}, value: RenderContext.() -> Unit)
render
Link copied to clipboard
js
open override fun render(context: RenderContext, styling: BoxParams.() -> Unit, baseClass: StyleClass, id: String?, prefix: String)
Central method that should do the actual rendering of a component.

Properties

size
Link copied to clipboard
js
type
Link copied to clipboard
js