# Card A bordered box for grouping related content — like a physical card you might hold in your hand. It has three distinct zones: a header (title + subtitle), a body (your content), and a footer (usually actions). --- ## Quick example ```csharp new Card( content: "
Your subscription renews on July 1.
", title: "Billing", description: "Current plan: Pro") ``` --- ## All the options ```csharp public Card( string content, string title = "", string description = "", string footer = "", string extraClasses = "") ``` | Parameter | What it does | |---|---| | `content` | The body of the card — always shown. Raw HTML. | | `title` | Optional bold heading at the top of the card. | | `description` | Optional smaller subtitle below the title. | | `footer` | Optional section at the bottom, typically holding action buttons. Raw HTML. | | `extraClasses` | Additional Tailwind classes on the outer `div` — useful for `max-w-sm`, `col-span-2`, etc. | The header section (title + description) is omitted entirely when both are empty. Same for the footer. --- ## Real-world examples ### A stats card on a dashboard ```csharp new Card( title: "Total Users", description: "All registered accounts", content: $"{userCount:N0}
") ``` ### A confirmation card with footer buttons Buttons and other components need to be pre-rendered to HTML strings when used inside `content` or `footer`: ```csharp string ToHtml(IHtmxComponent c) { var w = new System.Buffers.ArrayBufferWriterAll your data will be permanently removed.
", footer: ToHtml(new Button("Cancel", variant: "outline")) + ToHtml(new Button("Delete", variant: "destructive", type: "submit"))) ``` ### A grid of cards Cards are most commonly placed in a CSS grid in the page template: ```html{stats.UserCount:N0}
"); _revenue = new Components.Card( title: "Revenue", description: "This month", content: $"${stats.MonthlyRevenue:N2}
"); _orders = new Components.Card( title: "Open orders", description: "Awaiting fulfillment", content: $"{stats.OpenOrders}
", footer: """View all"""); } protected override void RenderUsersCard(HtmxRenderContext ctx) => _users.Render(ctx.Next()); protected override void RenderRevenueCard(HtmxRenderContext ctx) => _revenue.Render(ctx.Next()); protected override void RenderOrdersCard(HtmxRenderContext ctx) => _orders.Render(ctx.Next()); } ``` **GET handler** ```csharp [Handler] [MapGet("/dashboard")] public static partial class GetDashboardHandler { public record Query(); private static Task