Card Widget
Overview
The Card widget provides a container for grouped content with optional header, body, and footer sections. It supports borders and padding for visual separation.
Properties
title: Optional title text displayed at the topcontent: Main content textfooter: Optional footer text displayed at the bottomborder_style: Border style usingBorderStyleenumstyle: Style configuration for renderingpadding: Internal padding size
Methods
init(content: []const u8): Creates a new card with the given contentwithTitle(title: []const u8): Sets the card titlewithFooter(footer: []const u8): Sets the card footerwithBorder(border_style: BorderStyle): Sets the border stylewithPadding(padding: u16): Sets the internal paddingrender(ctx: *RenderContext): Renders the card with borders and content
Events
None - the card is a static display container.
Examples
Basic Card
zig
const tui = @import("tui");
const Card = tui.widgets.Card;
var card = Card.init("This is the card content.");Card with Title and Footer
zig
var card = Card.init("Main content here")
.withTitle("Card Title")
.withFooter("Card Footer");Styled Card
zig
var styledCard = Card.init("Styled content")
.withTitle("Styled Card")
.withBorder(.double)
.withPadding(2);